lifting functions to tuples?

Abraham Egnor aegnor at antioch-college.edu
Thu Nov 20 20:31:17 EST 2003


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 at haskell.org
>http://www.haskell.org/mailman/listinfo/haskell
>





More information about the Haskell mailing list