[Haskell-cafe] Looking for pointfree version

Kim-Ee Yeoh a.biurvOir4 at asuhan.com
Sun Feb 15 15:45:31 EST 2009


> import Control.Applicative
> 
> data Pair a = a :*: a
> 
> instance Functor Pair where
> 	f `fmap` (x :*: y) = f x :*: f y
> 
> instance Applicative Pair where
> 	(f :*: g) <*> (x :*: y) = f x :*: f y

The last f needs to be a g.

> 	pure x = x :*: x
> 
> pointfree :: (a -> b -> c) -> Pair a -> Pair b -> Pair c
> --pointfree o x y = pure o <*> x <*> y
> pointfree = ((<*>) .) . (<*>) . pure
> -- in the applicative paper notation:
> --pointfree o x y = [| o x y |]

Very nice. Aside: I wonder how much work it would be to
extend the pointfree tool to infer such equalities?

-- 
View this message in context: http://www.nabble.com/Looking-for-pointfree-version-tp21913653p22027350.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list