[Haskell-cafe] Is there a StateT but with resulting pair swapped?

Javran Cheng javran.c at gmail.com
Thu Feb 25 21:08:41 UTC 2021


Hi cafe,

I'm playing with alex recently and noticed that:

newtype Alex a
  = Alex {unAlex :: AlexState -> Either String (AlexState, a)}

which is almost StateT AlexState (Except String), and looks like I can make
a MonadError instance out of it.

Therefore I'm curious if there's any existing package that has newtype
StateT' s m a = StateT' (s -> m (s, a)) -- note the swapped pair here

so that I can just deriving (MonadError String) via StateT' AlexState
(Except String) to implement MonadError.

Thanks!
-- 
Javran (Fang) Cheng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210225/98267e3a/attachment.html>


More information about the Haskell-Cafe mailing list