[Haskell-cafe] "Universal" constraints?
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Sun Jun 21 06:09:25 UTC 2015
On 21 June 2015 at 15:55, Michael Walker <mike at barrucadu.co.uk> wrote:
> Hi all,
>
> I was wondering about constraints in class declarations. Suppose we have
> something like this:
>
> class Monad m => Store m where
> type Var m :: * -> *
>
> new :: a -> m (Var m a)
> read :: Var m a -> m a
> write :: Var m a -> a -> m ()
>
> [snip]
>
> ... it would be
> nice to be able to specify that all instances of our Store class have this
> property. Something like,
>
> class (Monad m, Eq (Var m a)) => Store m where ...
>
> But we can't write this! The `a` isn't in scope! What I really want to do is to
> be able to write class constraints like this,
Edward Kmett's constraints package has a Forall constraint that can be
used for cases like this (but may require some fiddling when this
constraint is used/required).
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list