[Haskell-cafe] a problem defining a monad instance
Jason Dagit
dagit at codersbase.com
Fri Nov 6 14:15:44 EST 2009
On Fri, Nov 6, 2009 at 10:19 AM, Neil Brown <nccb2 at kent.ac.uk> wrote:
> Petr Pudlak wrote:
>
> The problem is the (Ord b) condition, which is required for the Map
> functions. When I try to define the monad instance as
>
> instance Monad Distrib where
> return = dreturn
> (>>=) = dcompose
>
>
> obviously, I get an error at (>>=):
> Could not deduce (Ord b) from the context.
>
> Is there some way around? Either to somehow define the monad, or to
> achieve the same functionality without using Map, which requires Ord
> instances?
>
>
> Not being allowed constraints on the variables for class methods is
> probably the problem I have most frequently run into recently in Haskell (is
> there any way to fix this, or does it open up a whole can of worms?).
>
I believe this paper is intended to propose a solution:
http://tomschrijvers.blogspot.com/2009/11/haskell-type-constraints-unleashed.html
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/7e781819/attachment.html
More information about the Haskell-Cafe
mailing list