Safe use of unsafeCoerce?

Alastair Reid alastair at
Mon Apr 26 16:42:05 EDT 2004

> I'm after advice on whether the following example is a safe use of
> unsafeCoerce, and if it is safe, if it's worth it.

It looks like it is safe but it feels like using a sledgehammer to crack a 
nut ... in the presence of small children/ curious animals/ two left thumbs/ 
etc. so you have to take great care that none of them are near the nut each 
time you pull that sledgehammer out.

Given the function castFooToBar (which you tell us is safe), there's a number 
of obvious typesafe ways of writing this code, why not do so?  [I accept that 
there could be some reasons I just didn't see you mention any.]

Alastair Reid

More information about the Glasgow-haskell-users mailing list