<div dir="ltr">Hello all,<div><br></div><div>Normally, we don&#39;t worry *too* much about incorrect instances of standard classes (Num, Eq, Ord) etc.  They make the user&#39;s program wrong, but they don&#39;t compromise the type system.</div>

<div><br></div><div>Unfortunately, with the LVish parallel programming library we do have a situation where incorrect instances of Eq and Ord can cause the &quot;types to lie&quot;.  In particular, something that claims to be a pure, non-IO type, can actually yield a different result on different runs, including throwing exceptions on some runs but not others.</div>

<div><br></div><div>So what&#39;s the best way to lock down &quot;SafeEq&quot; and &quot;SafeOrd&quot; instances, taking control away from the user (at least with -XSafe is turned on)? </div><div><br></div><div>We could derive our own SafeEq and SafeOrd instances based on GHC.Generics.  BUT, that only helps if we can forbid the user from writing their own incorrect Generics instances when Safe Haskell is turned on.  It looks like GHC.Generics is currently marked as &quot;TrustWorthy&quot;:</div>

<div><br></div><div>    <a href="http://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html">http://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html</a><br></div>

<div><br></div><div>So.... could we get GHC.Generics marked as &quot;Unsafe&quot; and enable some more limited interface that is &quot;Trustworthy&quot;?  (Allowing the user ONLY to do &#39;deriving Generic&#39;).</div><div>

<br></div><div>This would be similar to the new policy in GHC 7.8 of only allowing derived Typeable instances...</div><div><br></div><div>  -Ryan</div><div><br></div></div>