My point was that this code seems excessively complex:
fun::(a->a1)->(Either a b)->Either a1 b fun f (Left x) = Left (f x) fun _ r@(Right x)= Right x
I'd like to avoid the destruction and construction in the third line by replacing the right hand side with r. However, the typechecker
then claims my type is wrong. How do I fix that?
-Alex-
______________________________________________________________ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
On Wed, 2 Mar 2005, Henning Thielemann wrote:
On Wed, 2 Mar 2005, Ben Lippmeier wrote:
You can play games with the type checker to force them to have the same type without changing the "meaning" of your function.
fun1' f (Left x) = if True then Left (f x) else Left x
Left (f x) `asTypeOf` Left x
?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe