Dan Piponi wrote: >> 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.
I couldn't agree more. In other words, splitAt is really to be thought of as a function that lives in the state monad. Regards, apfelmus -- http://apfelmus.nfshost.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe