<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 30, 2018, at 11:18 AM, David Feuer <<a href="mailto:david.feuer@gmail.com" class="">david.feuer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class="">Your simpler version won't even compile, </div></div></div></blockquote></div><br class=""><div class="">Here are the two versions edited so that both can compile (they needed some tweaks) for those playing along at home:</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font face="Courier" class="">{-# Language PatternSynonyms, FlexibleContexts, RoleAnnotations, RankNTypes, MagicHash #-}</font></div><div class=""><font face="Courier" class="">module Help where</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">import GHC.Exts hiding (Ptr)</font></div><div class=""><font face="Courier" class="">import Data.Type.Coercion</font></div><div class=""><font face="Courier" class="">import Unsafe.Coerce</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">{- Carter's version</font></div><div class=""><font face="Courier" class="">data Ptr a = Ptr Addr#</font></div><div class=""><font face="Courier" class="">type role Ptr nominal</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">castPtr :: Ptr a -> Ptr b</font></div><div class=""><font face="Courier" class="">castPtr = unsafeCoerce</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">ptrCoercible</font></div><div class=""><font face="Courier" class=""> :: (forall a b. Coercible (Ptr a) (Ptr b) => r)</font></div><div class=""><font face="Courier" class=""> -> r</font></div><div class=""><font face="Courier" class="">ptrCoercible r = r</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">ptrCoercion :: Coercion (Ptr a) (Ptr b)</font></div><div class=""><font face="Courier" class="">ptrCoercion = Coercion</font></div><div class=""><font face="Courier" class="">-}</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">data Addr = Addr_ Addr#</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">newtype Ptr a = Ptr_ Addr</font></div><div class=""><font face="Courier" class="">type role Ptr nominal</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">pattern Ptr :: Addr# -> Ptr a</font></div><div class=""><font face="Courier" class="">pattern Ptr a# = Ptr_ (Addr_ a#)</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">castPtr :: Ptr a -> Ptr b</font></div><div class=""><font face="Courier" class="">castPtr (Ptr a) = Ptr a</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">ptrCoercible</font></div><div class=""><font face="Courier" class=""> :: (forall a b. Coercible (Ptr a) (Ptr b) => r)</font></div><div class=""><font face="Courier" class=""> -> r</font></div><div class=""><font face="Courier" class="">ptrCoercible r = r</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">ptrCoercion :: Coercion (Ptr a) (Ptr b)</font></div><div class=""><font face="Courier" class="">ptrCoercion = Coercion</font></div></div></div><div class=""><br class=""></div></body></html>