Expected behavior of "deriving Ord"?

Conal Elliott conal at conal.net
Wed Mar 19 17:11:35 EDT 2008


I have an algebraic data type (not newtype) that derives Ord:

    data AddBounds a = MinBound | NoBound a | MaxBound
        deriving (Eq, Ord, Read, Show)

I was hoping to get a min method defined in terms of the min method of the
type argument (a).  Instead, I think GHC is producing something in terms of
compare or (<=).  Maybe it's defaulting min altogether.  What is the
expected behavior in (a) the language standard and (b) GHC?

The reason I care is that my type parameter a turns out to have partial
information, specifically lower bounds.  The type of min allows this partial
info to be used in producing partial info about the result, while the type
of (<=) and compare do not.

Thanks,  - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20080319/d0bfc1d8/attachment.htm


More information about the Glasgow-haskell-users mailing list