[Haskell-cafe] Adding Ord constraint to instance Monad Set?
Wolfgang Jeltsch
wolfgang at jeltsch.net
Wed Mar 31 08:48:35 EST 2004
Am Mittwoch, 31. März 2004 03:11 schrieb Benjamin Franksen:
> > instance Monad Set where
> > m >>= k = concatSets (mapSet k m)
> > return x = unitSet x
> > fail s = emptySet
> >
> > concatSets sets = foldl union emptySet (setToList sets)
> > instance (Eq b,Ord b) => Ord (Set b) where
> > compare set1 set2 = compare (setToList set1) (setToList set2)> [...]
> [...]
> Now, as i think a little more about it, i believe what you want to do makes
> no sense. The monad operation '>>=' works on monads over *different*
> 'element' (i.e. argument) types (look at the type of '>>='). Your
> implementation only works if argument types are the same. I can't see how
> this can be generalized to different argument types even if both are
> instances of class Ord.
I disagree. AFAICS, his implementation also works with different element
types. Am I overlooking something?
> [...]
> Ben
Wolfgang
More information about the Haskell-Cafe
mailing list