[Haskell-cafe] Suggestions for improvement

Gregory Crosswhite gcross at phys.washington.edu
Sun Oct 3 16:49:34 EDT 2010


  On 10/3/10 1:45 PM, 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

It is worth noting that such a function already exists in the standard 
libraries;  it is the &&& operator in Control.Arrow:

     blowup = uncurry (++) . (blowup . allButLast &&& lastToTheLength)

Cheers,
Greg


More information about the Haskell-Cafe mailing list