proposal: add 'unsafeCoerce'

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Nov 21 04:40:08 EST 2006


Taral <taralx at gmail.com> writes:

> On 11/20/06, Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk> wrote:
> >     newtype Wrapper a = Wrap a
> >     convert :: [a] -> [Wrapper a]
> >     convert xs = map Wrap xs
> 
> Interesting! Looks like the compiler lacks rules for optimizing "map
> id" &c.\

And not all compilers have optimisation phases.

> Your coercion does assume that the underlying runtime doesn't have
> some kind of type-tag implementation of type classes.

I believe this is guaranteed by the definition of newtype in the
Language Report.

Regards,
    Malcolm


More information about the Libraries mailing list