2

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?
  • `ExceptT e m a ~ m (Either e a)`, so `ExceptT e Identity (m a) ~ Identity (Either e (m a)) ~ Either e (m a)` while `ExceptT e m a ~ m (Either e a)` - which are not interchangeable. `group` and `split` can only be implemented for limited amount of transformers, and I think you cannot define one for ParsecT. IIRC ParsecT is defined via continuations, which is quite an outlier among monad transformers. – Abastro Jul 07 '22 at 14:34

0 Answers0