[Haskell-cafe] Ord for partially ordered sets

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Apr 24 13:59:37 UTC 2015


On Fri, Apr 24, 2015 at 11:27:46PM +1000, Ivan Lazar Miljenovic wrote:
> On 24 April 2015 at 23:17, Tom Ellis
> <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> > On Fri, Apr 24, 2015 at 11:06:07PM +1000, Ivan Lazar Miljenovic wrote:
> >> What is the validity of defining an Ord instance for types for which
> >> mathematically the `compare` function is partially ordered?
> >
> > I'm confused.  What is supposed to be the result of `g1 <= g2` when `g1` and
> > `g2` are not comparable according to the partial order?
> 
> With the proposed patch, it's the result of <= on the underlying [Int]Maps.

Ah, so it's a case of adding a valid Ord instance that isn't a natural one
for the particular datatype.  If you really need something like that, for
example to add your graphs to a Data.Set, then I would suggest a newtype
might be appropriate.

Tom



More information about the Haskell-Cafe mailing list