[Haskell-cafe] Adding Ord constraint to instance Monad Set?

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Wed Mar 31 10:28:35 EST 2004

On Wed, 31 Mar 2004, Simon Peyton-Jones wrote:

> I'm sorry to say that you just can't make Set an instance of Monad.  
> To make an instance of Monad for a type constructor T you must have a
> function
> 	bindT :: forall a b. T a -> (a -> T b) -> T b
> And there just *is* no such function for Set, because of the need for
> ordering.  There's a less polymorphic function
> 	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. But GHC doesn't accept this and an answer to
my surprise was
 (see http://www.haskell.org//pipermail/haskell-cafe/2004-March/005985.html) 

"Constraints on datatype declarations are a misfeature of Haskell, and
have no useful effect." 

Is this the final conclusion?

More information about the Haskell-Cafe mailing list