Proposal: instance MonadIO Q

Ryan Scott ryan.gl.scott at gmail.com
Thu Jul 23 16:16:39 UTC 2015


Template Haskell currently has runIO :: IO a -> Q a , which allows you
to run IO actions with a guarantee of IO effects' ordering in a single
splice (but not necessarily the order in which all the Q splices are
run). If runIO is indeed a monad morphism, then there is a law-abiding
MonadIO Q instance that could be added to transformers:

instance MonadIO Q where
  liftIO = runIO

This would be useful for dealing with monad transformer stacks with Q
as the base monad (for an example, see genifunctors
(https://github.com/danr/genifunctors/blob/4677bb57423b1b380ce9b50cc3d765a5c49a957a/Data/Generics/Genifunctors.hs#L47).
The only catch is that transformers would have to depend on
template-haskell. I think this would be okay since no quasiquotation
is involved, but I wanted to hear others' opinions.

Ryan


More information about the Libraries mailing list