[Haskell-cafe] Any precedent or plan for guaranteed-safe Eq and Ord instances?
Stijn van Drongelen
Wed Oct 2 16:57:43 UTC 2013
On Wed, Oct 2, 2013 at 4:17 PM, Tom Ellis <
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> What's the benefit of this requirement, as opposed to, for example
> False <= _ = True
I was trying to cover for void types, where the only sensible definitions
instance Eq Void where
_ == _ = error "void (==)"
instance Ord Void where
_ <= _ = error "void (<=)"
This is because reflexivity must be guaranteed, so undefined == undefined
may not yield False, but I doubt error "foo" == (let x = x in x) should
yield True either. But perhaps this exception deserves its own rule.
On Wed, Oct 2, 2013 at 5:36 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> * Stijn van Drongelen <rhymoid at gmail.com> [2013-10-02 15:46:42+0200]
> > I do think something has to be done to have an Eq and Ord with more
> > laws.
> > * Operators in Eq and Ord diverge iff any of their parameters are bottom.
> This outlaws the Eq instances of lists, trees, and other (co)recursive
> Furthermore, in this formulation, even Eq for tuples is illegal, because
> (undefined, something) == somethingElse
> is going to diverge.
I knew this was going to bite me in the ass. Let me try again:
* Operators in Eq and Ord may only diverge when any of their parameters are
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe