21 Nov
2003
21 Nov
'03
1:31 a.m.
That only works for type constructors (or similar encapsulation functions), but not for any sort of a -> b functions, i.e. (+1).
How about this:
liftTup :: (forall a. a -> f a) -> (x, y) -> (f x, f y) liftTup f (x,y) = (f x, f y)
Or ghc can infer the type if you write it like this:
liftTup (f::forall a.a ->f a) (x::x,y::y) = (f x::f x, f y::f y)
or simply:
liftTup (f::forall a.a ->f a) (x,y) = (f x, f y)
It works too! (ghci -fglasgow-exts)
liftTup Just (1, 'c') (Just 1,Just 'c')
Duncan
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell