unsafeCoerce and type aliases under type applications
wren ng thornton
wren at freegeek.org
Sun Dec 4 06:50:23 CET 2011
On 12/3/11 9:07 PM, Felipe Almeida Lessa wrote:
> On Sat, Dec 3, 2011 at 5:39 PM, Joachim Breitner
> <mail at joachim-breitner.de> wrote:
>> have used unsafeCoerce to change the type inside a container to a "type"
>> alias in real code, but your post makes me wonder: Under what
>> circumstances is that safe? Is that documented somehow? Can a tool or
>> the compiler decide for us whether it is safe?
>
> AFAIK, newtypes are safe, and for everything else you're on your own. =)
N.B., newtypes are safe in the sense of congruent rewriting; i.e., if X
is a newtype of Y, then we can rewrite X to Y (or Y to X) in any subterm
of the type term (just like if X = Y or X ~ Y). It's not just at the
top-level of the type term.
--
Live well,
~wren
More information about the Libraries
mailing list