
15 Feb
2009
15 Feb
'09
3:45 p.m.
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.