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

Erik Hesselink hesselink at gmail.com
Fri Aug 24 21:25:39 CEST 2012


I'm not sure if you already have something working, but we have
several in our codebase, all following a similar pattern. For example:

newtype GeoServer a = GeoServer { unGeoServer :: ReaderT
GeoServerState (ServerPartT IO) a }

instance MonadBaseControl IO GeoServer where
  newtype StM GeoServer a = StMGeoServer { unStMGeoServer :: StM
(ReaderT GeoServerState (ServerPartT IO)) a }
  liftBaseWith f = GeoServer (liftBaseWith (\run -> f (liftM
StMGeoServer . run . unGeoServer)))
  restoreM = GeoServer . restoreM . unStMGeoServer

Erik

On Wed, Aug 22, 2012 at 9:16 AM, 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.
>
> 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