<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 6:45 PM, namekuseijin <span dir="ltr"><<a href="mailto:namekuseijin@gmail.com">namekuseijin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mon, Sep 28, 2009 at 11:50 PM, Hong Yang <<a href="mailto:hyangfji@gmail.com">hyangfji@gmail.com</a>> wrote:<br>
> learn and use. In my humble opinion, Haskell has a lot of libraries, but<br>
> most of them offer few examples of how to use the modules. In this regards,<br>
> Perl is much much better.<br>
<br>
</div>The Perl call is spot on. Specially because Haskell has been<br>
incorporating so much syntatic sugar that it's almost looking Perlish<br>
noise already:<br>
<br>
import Data.Array.Diff<br>
import Data.IArray<br>
<br>
update :: (Char -> [Int]) -> DiffArray Int ModP -> Char -> DiffArray Int ModP<br>
update lookup arr c = arr // (map calc . lookup $ c)<br>
where<br>
calc i = (i, (arr ! i) + (arr ! (i-1)))<br>
<br>
solve line sol = (foldl' (update lookup) iArray line) ! snd (bounds iArray)<br>
where<br>
iArray = listArray (0, length sol) $ 1 : map (const 0) sol<br>
lookup c = map (+1) . findIndices (== c) $ sol<br>
<br>
<br>
I've not been following Haskell too much and am completely lost when<br>
reading code like that. I understand (+1), : and ! but what the hell<br>
are . and $ for?<br>
And that weird monad symbol in the Haskell logo is not even used! >>=<br>
Not quite the worst example of such line noise much of Haskell<br>
idiomatic code uses nowadays, though.<br>
<br>
Point is: >>= . $ : ! `` and meaningful whitespace are all nice<br>
shortcuts, but also hairy confusing...<br>
<div><div></div><br></div></blockquote><div><br>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 :).<br>
<br>Michael <br></div></div></div>