- Equational style: A few years ago, I prototyped some decently complex code in Q, so I am unphased by the equational style of Haskell. (Equational style is when a function can be built with multiple declarations, each declaration covering specific variants of the function’s arguments). The style is more or less efficient depending of the ratio of context arguments to “local arguments”. Therefore I would not argue if the style is better or worse than single definition declarations.
- “where” declaration are great. Its top down style often provides a better reading and they also result in less deep indentation.
- “Let indentation” rule is a drag: Needing to align right after the beginning of the left hand side implies 5 or more indentation spaces. You can get around that by dangling the “let” alone on its line but that is no real gain. Luckily, in many cases the “where” statement saves the day.
- Non-ascii characters like the λ character are “a bit strange. I tried them but found them hard to read on my little laptop. I have now reverted back to ascii chars.
Wednesday, June 15, 2011
From F# to Haskell
I am learning Haskell by converting F# code: I take it piece by piece from Visual Studio and copy it to the Leksah IDE. Then I reedit it to compile. I then refactor it for style. These are the basic style changes: