Hi Kirstin,

| Surely this is obvious, but I cannot figure out how to properly deal with
| class constraints and monads. For instance, when trying 
| 
| instance Monad Set.Set where 
|   xs >>= f     =  Set.unionSet (Set.map f xs)
|   return x     =  Set.single x
|   fail s       =  Set.empty
| 
| hugs complains that it "Cannot justify constraints in instance member
| binding" for >>=. unionSet type is Eq a => Set (Set a) -> Set a

This is a long standing problem in Haskell.  Off the top of my head, I
can think of a couple of papers that talk about ways of addressing it.
The first is John Hughes' paper on "Restricted Datatypes in Haskell"
from the 1999 Haskell Workshop:

    http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps

The second is Simon Peyton Jones' paper on "Bulk types with class" from
the 1996 Glasgow FP Workshop:

    http://research.microsoft.com/Users/simonpj/Papers/collections.ps.gz

Hope these references are of some help!

All the best,
Mark

----------------------------------------------------------------------------
[EMAIL PROTECTED]  Pacific Software Research Center, Oregon Graduate Institute
    Looking for a PhD?  Interested in joining PacSoft?  Let us know!


Reply via email to