On Wed, Sep 30, 2009 at 6:45 PM, namekuseijin <namekusei...@gmail.com>wrote:
> On Mon, Sep 28, 2009 at 11:50 PM, Hong Yang <hyang...@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) > where > calc i = (i, (arr ! i) + (arr ! (i-1))) > > solve line sol = (foldl' (update lookup) iArray line) ! snd (bounds iArray) > where > 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... > > I overall agree with the sentiment (I avoid declaring operators at all costs), but the example is a bad one. $, ., and >>= are all very basic to Haskell, and should be picked up almost immediately. As far as becoming line noise like Perl, well, I happen to like Perl :). Michael
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe