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

Peter Verswyvelen bugfact at gmail.com
Wed Mar 25 11:35:07 EDT 2009

On Wed, Mar 25, 2009 at 4:09 PM, Simon Marlow <marlowsd at gmail.com> wrote:

> But it only works out nicely because the ordering of the components of the
> pair returned by splitAt matches the ordering that the state monad expects
> (and I can never remember which way around they are in Control.Monad.State).

Now you mention this, I often had to write a little function

swap :: (a,b) -> (b,a)

It seems many other authors have done the same in their own modules. Maybe
this should be part of the Prelude?

> Try doing it with mapAccumL, which is arguably the right abstraction, but
> has the components the other way around.
> Cheers,
>        Simon
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090325/e860dace/attachment.htm

More information about the Haskell-Cafe mailing list