
20 Nov
2006
20 Nov
'06
4:19 p.m.
Taral
* casting from a newtype to the contained value (or vice versa).
Why do you need to cast for this? You have "casting" operators in the form of the constructor and (synthesized) destructor.
OK, to be more explicit, newtype Wrapper a = Wrap a convert :: [a] -> [Wrapper a] convert xs = map Wrap xs Here, the convert function actually traverses the list at runtime. convert' xs = unsafeCoerce xs But this version does not - it is a type-avoiding identity. Regards, Malcolm