constant space `minimum'

Simon Peyton-Jones simonpj at
Wed Sep 29 09:43:45 EDT 2004

| I meant that the implementation like
|              minimum [x]      = x
|              minimum (x:y:xs) = if x > y then minimum (y:xs)
|                                 else          minimum (x:xs)

It would be great if this was the defn of minimum in the Report. But it

data T = T1 | T2
instance Ord T where
   min x T2 = T2
   min x y   = error "urk"

Now try
	minimum [T1,T2,T2]
your defn gives "urk", but the Report gives T2.

Stupid, I know, but that's what it says.

So the best thing seems to be to give monomorphic instances of minimum
for types where we know the instances!


More information about the Glasgow-haskell-users mailing list