Magic Haskell code completions in Vim!

7/05/2011

UPDATE: This project is on hold for now. Many people have pointed out that the snipMate VIM plugin can probably handle many of these completions. I may make a collection of those at some point, but I no longer have much interest in finishing this.

I’m trying something new: putting code-in-progress up on github while I work on it. So! I love haskell so freaking much I’ve started creating a vimscript to improve the typeability of the language in the vim editor, and the working name is: haskomplete.vim

The script looks at the context of your cursor and fills in stuff when you type CTRL-H. For instance, this:

func1, func2

becomes…

func1, func2 :: ^
func1 = undefined
func2 = undefined

…with the cursor positioned where I show the carat.

Check out the README.md on github for installation details.

I’ve only implemented a few of my planned completions so far. I’ll give another shout when it’s more complete.

In the meantime please send me a pull request with bug fixes, your own awesome completions, etc. or just tell me how much you think you might love it. I would love if this became something of a community project.

4 Comments

PEZ: the Potentially-Excellent Zipper library release

19/04/2011

I’m happy to announce the release of a zipper library I named PEZ! I’ve been learning and building this silly library almost as long as I’ve been learning haskell. It’s not as great as it could be, but I’m releasing it now because it’s about time.

You can check it out with a:

cabal install pez

The library provides a generic zipper that can be used on all types in the Typeable class, for which the user defines (or generates) lenses from the excellent fclabels package.

Since Typeable instances are deriveable in GHC and fclabels lenses can be generated with a line of TH code, this makes for a very pain-free and intuitive zipper.

The Typeable class gives us the ability to move up and down through complex mutually-recursive structures, even “down through” reversible computations!

The lenses from ‘fclabels’ give us a way of referring to elements in data types in a way that is composable, allowing us to store our history as continuations and provide powerful mechanisms for “saving” a path through a data structure.

There is more to do: in particular I haven’t yet examined any of the performance characteristics of the approach I take, but please try it out and let me know how it works for you!

No Comments

Synchronized Concurrent IO Actions

24/02/2011

This is a bit of literate haskell code that works through a system for running concurrent IO computations that are synchronized on a stream. So we have many “nodes” of the type :: a -> IO () running concurrently on a single stream, where we would like each node to wait until all nodes have processed a stream element before any are allowed to proceed onto the next element.

This was motivated by the desire to simulate a system in which many nodes are interacting independently according to a time-synchronized algorithm. So the “stream” the nodes process is time.

I wanted to use real concurrency because it sounded fun. It would of course be possible to simulate a time-synchronized system without using real concurrency.

Read the rest of this article »

No Comments