proposal: add 'unsafeCoerce'
David House
dmhouse at gmail.com
Tue Nov 21 10:11:18 EST 2006
On 20/11/06, Simon Marlow <simonmarhaskell at gmail.com> wrote:
> * cast that changes a phantom type, or changes a type that is not
> reflected by a part of the value,
> eg. 'unsafeCoerce (Left 3) :: Either Int a' should be fine for any 'a',
Couldn't we have the following for this case?
castEitherL :: Either a b -> Either a c
castEitherL (Left x) = Left x
castEitherL z = z
castEitherR :: Either a b -> Either c b
castEitherR (Right x) = Right x
castEitherR z = z
Not general, but it'd work in this case. And no need for unsafeCoerce.
--
-David House, dmhouse at gmail.com
More information about the Libraries
mailing list