[Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc.

namekuseijin namekuseijin at gmail.com
Wed Sep 30 12:45:47 EDT 2009

On Mon, Sep 28, 2009 at 11:50 PM, Hong Yang <hyangfji at gmail.com> wrote:
> learn and use. In my humble opinion, Haskell has a lot of libraries, but
> most of them offer few examples of how to use the modules. In this regards,
> Perl is much much better.

The Perl call is spot on.  Specially because Haskell has been
incorporating so much syntatic sugar that it's almost looking Perlish
noise already:

import Data.Array.Diff
import Data.IArray

update :: (Char -> [Int]) -> DiffArray Int ModP -> Char -> DiffArray Int ModP
update lookup arr c = arr // (map calc . lookup $ c)
   calc i = (i, (arr ! i) + (arr ! (i-1)))

solve line sol = (foldl' (update lookup) iArray line) ! snd (bounds iArray)
   iArray = listArray (0, length sol) $ 1 : map (const 0) sol
   lookup c = map (+1) . findIndices (== c) $ sol

I've not been following Haskell too much and am completely lost when
reading code like that.  I understand (+1), : and ! but what the hell
are . and $ for?
And that weird monad symbol in the Haskell logo is not even used! >>=
Not quite the worst example of such line noise much of Haskell
idiomatic code uses nowadays, though.

Point is:  >>= . $ : ! `` and meaningful whitespace are all nice
shortcuts, but also hairy confusing...

More information about the Haskell-Cafe mailing list