[Haskell-cafe] Verbosity of imperative code (was: Learning Haskell)

Henning Thielemann lemming at henning-thielemann.de
Thu Dec 8 09:03:09 EST 2005


On Wed, 7 Dec 2005, J. Garrett Morris wrote:

> On 12/7/05, Robin Green <greenrd at greenrd.org> wrote:
> > Let's say you want to write a function
> >
> > seqPair :: (Monad m) => (m a, m b) -> m (a, b)
> >
> > which returns a computation which does the left computation followed by the
> > right computation (i.e. it's like the sequence function, but for pairs
> > instead of lists).
>
> In this case, I believe it is as simple as
>
> import Control.Monad (liftM2)
>
> seqPair = liftM2 (,)

seqPair = uncurry (liftM2 (,))



More information about the Haskell-Cafe mailing list