[Haskell-cafe] How to implement instance of MonadBaseControl IO

Chris Wong chrisyco+haskell-cafe at gmail.com
Wed Aug 22 10:17:03 CEST 2012

On Wed, Aug 22, 2012 at 7:16 PM, yi huang <yi.codeplayer at gmail.com> wrote:
> I have a `newtype Yun a = Yun { unYun :: ReaderT YunEnv (ResourceT IO) a }`
> , and i need to define an instance of `MonadBaseControl IO` for it.
> Newtype instance deriving don't work here. I guess the answer is simple, i
> just can't figure it out, hope anybody can lightening me.

I had the same problem some time ago. In my case it's StateT instead
of ReaderT, but it's the same idea. The tough part is getting around
the crazy CPS -- it's supposed to help with performance, but at the
cost of usability.

Anyway, here's my implementation:

Michael Snoyman has written a tutorial as well:
I'd recommend printing it out and going over it slowly -- it can get
pretty dense at times.


> Best regards.
> Yihuang.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list