
6 Jul
2005
6 Jul
'05
4:18 a.m.
On Wed, 6 Jul 2005, wenduan wrote:
Dear all,
Suppose we have defined two functions as below:
case :: (a -> c,b -> c) -> Either a b -> c case (f, g) (Left x) = f x case (f, g) (Right x) = g x
It seems to be case == uncurry either Prelude> :info either -- either is a variable either :: forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
plus :: (a -> b, c -> d) -> Either a b -> Either c d plus (f, g) = case(Left.f, Right.g)
of plus should be: plus :: (a -> c, b -> d) -> Either a b -> Either c d
That signature looks correct and it is accepted Prelude> let plus = (\(f,g) -> uncurry either (Left . f, Right . g)) :: (a->c,b->d) -> Either a b -> Either c d