Archive for the ‘Haskell’ Category

More syntax highlighting

Thursday, May 14th, 2009

I can’t live without pretty colours in my editor so I threw together some Happy and Alex highlights. No indenting or anything like that because effort. (If you set autoindent, though, the indents leaking out from haskell.vim sometimes help a little, when they don’t do completely the wrong thing.)

They’re both public domain, I suppose, so if anyone wants to make them not suck, please do!

Cabal.vim 0.1

Monday, March 23rd, 2009

Since the last post, quite a lot of things have been added. Of course, most of them are so minor (fixing typos? Oh my!) that I didn’t bother posting about them. But there have been enough now that I might as well bullet point them up, for people who don’t feel like doing darcs changes. :)

(more…)

cabal-vim

Friday, March 13th, 2009

I apparently cannot get enough of Vimscript, so after someone on the Haskell-café list asked about it, I wrote a syntax mode for Cabal files. Hooray. (Hopefully no-one’s already written one…)

Not much to it at the moment, though there is an attempt at automatic indenting, since that was the bit I was missing the most.

It’s here if anyone wants it, or as it’s darcsed up:

darcs get http://patch-tag.com/publicrepos/cabal-vim

Slight updates to haskell.vim

Sunday, March 8th, 2009

Since the Vim syntax file for Haskell was last updated, there have been a bunch of syntax extensions in GHC1, like rank-n types, arrow syntax, and allsorts. I decided to add a few of these.

You can get it here. You might want to back up your old one; I’m pretty sure I haven’t broken anything, but my testing wasn’t exactly thorough (mostly consisting of checking the new syntax worked, rather than whether the old syntax was broken).

Update! if anyone’s seen this yet, then please download it again. The first time, (#) would make the # part of an unboxed tuple bracket. That’s fixed now. (See: lack of testing.)

(more…)


  1. If you don’t use GHC perhaps these updates won’t be very useful… 

I just noticed something

Saturday, December 6th, 2008

The applicative functor instance for (r ->) is:

instance Applicative ((->) r) where
    pure = const
    f <*> g = \x -> f x (g x)

Look familiar? Of course, I is missing, but it’s just pure <*> undefined1 (or id but that’s cheating) anyway.

I dunno what implications this has, other than that you could in theory write a whole program with just pure and (<*>) if you really wanted. But then it is 5.50am so there’s probably something obvious I’m just not seeing.


  1. I wanted to put pure <*> pure but when I checked this actually worked GHCi shouted at me for the second pure being ambiguous. So bleh. 

Applicative functors and actions

Friday, August 29th, 2008

This is obvious and all, but it suddenly clicked why you can’t choose different paths inside of Applicative. What I mean is that things of this form aren’t possible:

something = do p' <- getABool
               if p then putStrLn "it was true"
                    else putStrLn "it wasn't"

However, I couldn’t think why. Well, the reason is that the methods of Applicative are pure and (<*>) (obviously), which are like return and ap (also obviously). But! Note that with (<*>) (and ap) you can only work inside the functor:

mf `ap` mx ≡ mf >>= \f -> mx >>= \x -> f x

On other words, you would have to evaluate both x and y in something, somewhat like this:

something' p x y = do p' <- p
                      x' <- x
                      y' <- y
                      return (if p then x' else y')
 
-- or
somethingA p x y = f <$> p <*> x <*> y
    where f p x y = if p then x else y

…evaluating both x and y and (in IO) performing both their side effects.

I’m sure this explanation is terrible, but it helped me at least?

Still none for D though

Friday, January 18th, 2008

Oh, also, qtHaskell. :yaay: I’ve wanted this for so long (well, since I knew about Qt and Haskell, which I suppose isn’t that long), and, and, it’s exactly what I wanted!

Except for the inexplicable lack of QProgressBar, but let’s not pick.

PS. Advertising :D

They forgot M (monadine)

Tuesday, October 30th, 2007

http://www.icfpcontest.org/Endo.pdf

Endo is an alien life form, belonging to the species of the Fuun. Endo needs your help! Earth’s environmental conditions can be harsh for a life form not properly adapted. Endo had the bad luck of being dropped on Earth by an Interstellar Garbage Collector. Both the life form and its faithful space ship Arrow were severely hurt in the crash, and even worse, after leaving the damaged space craft Endo was hit by a cargo container that was also dropped by the Garbage Collector.

Fuun DNA can be represented as a finite sequence consisting of four bases, denoted by the four letters I (infinine), C (continuine), F (functorine), and P (polymorphine).

The puns, they just won’t stop.