
2 Mar
2005
2 Mar
'05
9:39 a.m.
On Wed, 2 Mar 2005 09:20:15 -0500 (Eastern Standard Time), S.
Alexander Jacobson
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?
In your example, 'r' has type "Either a b" which doesn't match "Either a1 b". And you can "fix" it with some unsafeCoerce# magic. (: -- Friendly, Lemmih