[Haskell-cafe] Re: Suggestions for improvement

N. Raghavendra raghu at mri.ernet.in
Mon Oct 4 00:49:15 EDT 2010

At 2010-10-03T22:45:30+02:00, Dominique Devriese wrote:

> Additionally, you can't combine the functions (blowup . allButLast)
> and lastToTheLength into a function that returns a pair like you seem
> to attempt. You need a function like the following for that:
> comma :: (a -> b) -> (a -> c) -> a -> (b,c)
> comma f g x = (f x, g x)
> Then you could say:
> blowup = (uncurry (++)) . comma (blowup . allButLast) lastToTheLength

Thanks, I'll try that.

> Ignore this if you haven't read about Applicative or type classes yet,
> but using the Applicative instance for arrow types (->) a, you can
> also write
> comma = liftA2 (,)

I hadn't come up to that point, but will read about it now.


N. Raghavendra <raghu at mri.ernet.in> | http://www.retrotexts.net/
Harish-Chandra Research Institute   | http://www.mri.ernet.in/
See message headers for contact and OpenPGP information.

More information about the Haskell-Cafe mailing list