Re: Expected behavior of "deriving Ord"?

2008-03-31 Thread Conal Elliott
The issue is more than just efficiency. It's vital that these improving values get evaluated as little as possible. In my use for functional reactivity, they represent the times of future event occurrences. Your (<=)-via-min idea might work in some cases, though useful pointer equality can be pr

Re: Expected behavior of "deriving Ord"?

2008-03-31 Thread Christian Maeder
Christian Maeder wrote: > Conal Elliott wrote: >> The type argument I ran into trouble with represents a value as a list >> of increasing lower bounds, ending in the exact value. min produces >> lower bounds from lower bounds and so is immediately productive before >> even knowing which argument i

Re: Expected behavior of "deriving Ord"?

2008-03-22 Thread Christian Maeder
Conal Elliott wrote: > The type argument I ran into trouble with represents a value as a list > of increasing lower bounds, ending in the exact value. min produces > lower bounds from lower bounds and so is immediately productive before > even knowing which argument is the lesser one. Is this on

Re: Expected behavior of "deriving Ord"?

2008-03-20 Thread Conal Elliott
Oh -- partial & partial. Thanks. I was pretty puzzled there. The type argument I ran into trouble with represents a value as a list of increasing lower bounds, ending in the exact value. min produces lower bounds from lower bounds and so is immediately productive before even knowing which argum

Re: Expected behavior of "deriving Ord"?

2008-03-20 Thread Christian Maeder
Conal Elliott wrote: > AddBounds makes total orders from total orders. It just adds new least > and greatest elements. > > The problem with the derived instance is that it doesn't exploit the > potential laziness of min on 'a'. Because of their types, min it can > produce partial info from parti

Re: Expected behavior of "deriving Ord"?

2008-03-20 Thread Conal Elliott
AddBounds makes total orders from total orders. It just adds new least and greatest elements. The problem with the derived instance is that it doesn't exploit the potential laziness of min on 'a'. Because of their types, min it can produce partial info from partial info and (<=) and compares can

Re: Expected behavior of "deriving Ord"?

2008-03-20 Thread Christian Maeder
Conal Elliott wrote: > I have an algebraic data type (not newtype) that derives Ord: > > data AddBounds a = MinBound | NoBound a | MaxBound > deriving (Eq, Ord, Read, Show) The class Ord is not suited for partial orders. If you write your own Ord instances anyway, I'd suggest to intro

Re: Expected behavior of "deriving Ord"?

2008-03-19 Thread Conal Elliott
Thanks for the pointers. I'd found 10.1 but hadn't noticed 10.5. So I suggest that you use an explicit Ord instance and define min/max the > way you want. > Yep. That's my solution: instance Ord a => Ord (AddBounds a) where MinBound <= _ = True NoBound _ <= MinBound =

Re: Expected behavior of "deriving Ord"?

2008-03-19 Thread Duncan Coutts
On Wed, 2008-03-19 at 14:11 -0700, Conal Elliott wrote: > 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 >

Expected behavior of "deriving Ord"?

2008-03-19 Thread Conal Elliott
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