Tuesday, May 31, 2011

Moving to Haskell (from F#)

I am a bit busy these days helping out with architecture and agile development for a large ticker plant and calculation farm. Therefore when I sit down to program (using my slack time!), it needs to deliver bang for the buck. I have my sturdy little Dell X1 laptop, visual studio 2010 and F#; and although I have suffered by F# limitations, I have not been blocked. Yet now I am stuck, my needs are getting seriously heavy and the F# type system cannot cope. One issue is that monadic programming style in F# needs to be defined with the help of a class and this class needs explicit types, and the other issue is that there is no explicit way to define type class, or types with localized polymorphic definitions. In a non monadic framework I have been bootstrapping my polymorphic types on start-up: The trick is to wrap all functions of a module in to one big function whose arguments are the functions that constrain the types as would the parameters to a type class; The big function returns one big tuplet or record with all the functions of the module that have now been “bound” to a type structure (you can still have some unbound types to cover the localized polymorphic needs). The application will then first bind all modules as functions, the “main” then proceeds with the bound functions. Yet now I am stuck as the monadic programming style need the use of explicit type variable and this does not work with the trick above. I could write all my monadic code “raw”, as functions. But that beats the purpose of the abstraction. Therefore…

I am ditching F# as a core language; I’ll generate it when I want .net compatibility with the advantage that it is a functional language and can hope that the compiler will do a good job with it. In search of a replacement, I see only three candidates: ocaml, Scala, and Haskell. I have always liked ocaml, but I feel the support for it diminishing. I see Scala as F#; better in some ways, worse in others, it is only a candidate for those that are forced to stay in a Java and JVM environment. Therefore Haskell it will be by elimination.

Haskell is easy to install on Windows (XP on my old laptop):
  • Install a minimum Cygwin to have the grep function.
  • Install Haskell (HaskellPlatform)
  • Install Leksah (a Haskell IDE)
I’ll tell you what I like and dislike about Haskell in a future post.

No comments: