suggestion: A common type class for mutable variables

Edward Kmett ekmett at
Thu May 30 22:59:21 CEST 2013

There are no MPTCs or type families in base outside of the GHC.* at this time and there are several libraries that provide this functionality as a layer on top. 

I don't really see the need to bless one over the rest by folding it into base, as there are several points in the design space available and each is better for different audiences. MPTCs+FD for portability, MPTCs+TFs for GHC-specifics, even MPTCs without either or with the FD running the other direction, to permit the combinatory to work on more ref types in exchange for worse inference.

In fact there is a strong case against including it in base:

If the FD or TF went from the monad to the ref type, then you'd want it to auto lift over transformers without orphan instances, but this would require transformers to break Haskell 98/2010, which isn't palatable given transformers' stated goals!

The requisite layering is better served (and only possible) by this being a non-base package, which is precisely the status quo.



On May 30, 2013, at 2:53 PM, Petr Pudlák <petr.mvd at> wrote:

> Dear Haskellers,
> I noticed that there is no common typeclass that would unify STRefs and IORefs. We already have MArray for ST(U)Arrays and IO(U)Arrays, so why not for references as well? This would allow writing generic code that can use both ST- and IO-based variables.
> I've found that there is a package that provides such a type class:
> I'd suggest to add similar functionality to base, perhaps with some different wording - I'd rather use Data.MRef (as "mutable reference").
> If there is some interest in it, I'd prepare a concrete code for consideration.
>  Best regards,
>  Petr Pudlak
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list