[Haskell-cafe] Adding Ord constraint to instance Monad Set?
simonpj at microsoft.com
Wed Mar 31 09:43:32 EST 2004
| > bindSet :: forall a b. (Ord a, Ord b)
| > => T a -> (a -> T b) -> T b
| To translate the question from my problem to this one:
| What would be if Set would be declared within Ord context, i.e.
| data (Ord a) => Set a = ...
| ? Now it would be safe to use Set as Monad because Sets could only
| constructed from Ord types.
No, the same problem arises. You could imagine that every Set contains
its Ord methods. Then bind wouldn't need to pass them. But
return :: Monad a => a -> m a
The Set instance would have to be
unitSet :: a -> Set a
Where does the Ord dictionary come from?
No, this won't work. Some of this stuff is discussed in a very old
paper of mine
But I can't promise it covers this particular issue, and it predates
| "Constraints on datatype declarations are a misfeature of Haskell, and
| have no useful effect."
| Is this the final conclusion?
Yes, it is, I believe. Constraints on data type declarations are a
mis-feature. I tried to get them removed, but there was some argument
that they could be made useful (see John Hughes's paper "Restricted data
types in Haskell", Haskell workshop 1999), and they stayed.
More information about the Haskell-Cafe