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

plus :: (a -> b, c -> d) -> Either a b -> Either c d
plus (f, g) = case(Left.f, Right.g)

My question is regarding to the function signature of 'plus' , in its signature, does the 'a' in 'a -> b' and in 'Either a b', must be instantiated to the same object when the function is applied?E.g.,Either a b is instantiated to 'Either Char b', will the 'a' in 'a -> b' be instantiated to 'Either Char b'?Furthermore, are the two bs in 'a -> b' and 'Either a b' not conflicting?What I thought at first the signature of plus should be: plus :: (a -> c, b -> d) -> Either a b -> Either c d?Anyone know where I was wrong?

--
X.W.D

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to