[Haskell-cafe] about Haskell code written to be "too smart"

Yitzchak Gale gale at sefer.org
Tue Mar 24 16:17:15 EDT 2009


Manlio Perillo complained about:
>> buildPartitions xs ns = zipWith take ns . init . scanl (flip drop) xs $ ns

Miguel Mitrofanov wrote:
> takeList = evalState . mapM (State . splitAt)

Ha! Bravo!

As the author of the offending zipWith/scanl version,
I can say that love those State monad one-liners.
However, ironically, I stopped using them for pretty
much the same reason that Manlio is saying.

The difference is that zipWith and scanl are classic Haskell
idioms that any Haskell programmer will learn fairly early
on. Whereas State monad one-liners used to be thought of
as new and fancy and esoteric. But now they are becoming
more mainstream, so perhaps I should go back to them.

So the bottom line is that Manlio is right, really. It's just
that Haskell is still very different than what most
programmers are used to. So it does take a while to
get a feeling for what is "too smart".

Yitz


More information about the Haskell-Cafe mailing list