[Haskell-cafe] Any precedent or plan for guaranteed-safe Eq and Ord instances?

Tillmann Rendel rendel
Wed Oct 2 11:19:38 UTC 2013


Roman Cheplyaka wrote:
> It still seems to fit nicely into Safe Haskell. If you are the
> implementor of an abstract type, you can do whatever you want in the Eq
> instance, declare your module as Trustworthy, and thus take the
> responsibility for soundness of that instance w.r.t. your public API.

A possible problem with marking "instance Eq" as an unsafe feature is 
that many modules would be only Trustworthy instead of Safe. So if I 
don't trust the authors of a module (because I don't know them), I 
cannot safely use their code just because they implement their own Eq 

That would go against my "every purely functional module is 
automatically safe because the compiler checks that it cannot launch the 
missiles" understanding of Safe Haskell.

Actually, Eq instances are not unsafe per se, but only if I also use 
some other module that assumes certain properties about all Eq instances 
in scope. So in order to check safety, two independent modules (the 
provider and the consumer of the Eq instance) would have to cooperate.


More information about the Haskell-Cafe mailing list