[Haskell-cafe] Implementing `MonadBaseControl IO` for application type

Magnus Therning magnus at therning.org
Sat Feb 2 11:28:32 UTC 2019


I'm getting stuck on implementing `MonadBaseControl IO` for my application
context type. What I have so far (in a minimized example) is

data Env = Env {envBalance :: !(TVar Int)}

newtype AppM a = AppM { unAppM :: ReaderT Env IO a }
  deriving (Functor, Applicative, Monad, MonadIO, MonadReader Env)

instance MonadBase IO AppM where
  liftBase = liftIO

instance MonadBaseControl IO AppM where
  type StM AppM a = a
  liftBaseWith f = undefined
  restoreM = return

I'm so utterly stuck on the definition of `liftBaseWith`... but I'm not
100% sure on the other bits either, though it "feels right".

Any tips on how I should go about it?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190202/cc0a5afb/attachment.html>

More information about the Haskell-Cafe mailing list