How to Group and Split Monad Transformers using Identity

125 views Asked by At

I am currently learning about Monad Transformers and noticed that the MonadTrans class that the library I am using (Mageparsec) implements, does not define any way to group and split apart the Transformer, where I would expect these functions to both exist and have this signature.

group:: (MonadTrans t, Monad m) => t Identity (m a) -> t m a
split:: (MonadTrans t, Monad m) => t m a -> t Identity (m a)

... And be defined as inverses of each other. The reason I was expecting some functions like this to be defined, is because without them I have no clue how I would define group $ f <$> split tmx <*> split tmy. Not that they would be only useful for that!

To my current knowledge: (TransMonadT m) a is isomorphic to TransMonad (m a)

  • Do these functions exist within Control.Monad.Trans?
  • And if not how do I define them in general?
  • And if I cannot define them in general, at the very least how do I define them for ParsecT?
0

There are 0 answers