Wednesday, April 25, 2012

ImperativeHaskell and Loops

ImperativeHaskell- has been released and is posted on Hackage. This version has an addition that significantly simplifies using ImperativeHaskell with existing code. In this version I've added a template function "liftOp" which uses the type of its argument to convert its argument into a function in the style of ImperativeHaskell. There are more details in the documentation. I have noticed a potential problem however. "continue';" and "break';" will only work inside of a loop, and will cause an error if used outside of a loop. A type level way of ensuring that they are only used in loops is clearly needed. Turning "Control" into a GADT and adding a phantom type turned out to not be the way (necessarily). Perhaps some logic programing with typeclasses in combination with this method is necessary.


  1. What's your goal/aspirations with ImperativeHaskell? It's a fascinating look into turning functional semantics into imperative style (some languages have been taking the reverse approach).

    Jonathan Dunlap

  2. It started as just a proof of concept. I wanted to see how close I could get Haskell to look like a traditional C style imperative language with references. Now I want to use this as a teaching tool to get people who don't know any functional languages, but have a history with imperative languages, programming realistic programs quicker in Haskell.

    I've seen a lot of people start learning Haskell and get way too frustrated with the barrage of new concepts and inability to immediately do anything useful or at all similar to anything they have ever seen before. While being pushed in the icy water of the Haskell pool works for some, it definitely deters most.

    I think it is better to start teaching people with something they can actually use, then more slowly introduce new concepts and different ways of coding.


1. Do be civil.
2. Reasonable criticisms are welcome, but personal opinions are not.
3. These posts are not for evangelizing languages, but for contemplating interesting properties.