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

Dan Piponi dpiponi at gmail.com
Tue Mar 24 17:26:32 EDT 2009


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

> However, ironically, I stopped using them for pretty
> much the same reason that Manlio is saying.

Are you saying there's a problem with this implementation? It's the
only one I could just read immediately. The trick is to see that
evalState and State are just noise for the type inferencer so we just
need to think about mapM splitAt. This turns a sequence of integers
into a sequence of splitAts, each one chewing on the leftovers of the
previous one. *Way* easier than both the zipWith one-liner and the
explicit version. It says exactly what it means, almost in English.
--
Dan


More information about the Haskell-Cafe mailing list