[Haskell-cafe] Why does shift's function return result in Cont and reset reinsert result into Cont again?

Albert Y. C. Lai trebla at vex.net
Tue Jan 12 20:38:00 UTC 2016


On 2016-01-11 05:28 AM, Dmitriy Matrosov wrote:
> Wouldn't it be simpler (better?) to just define shift/reset like
>
> > shift' :: ((a -> w) -> w) -> Cont w a
> > shift'      = cont
> >
> > reset' :: Cont w w -> w
> > reset' m    = runCont m id
> >
> > shiftT' :: ((a -> m w) -> m w) -> ContT w m a
> > shiftT'     = ContT
> >
> > resetT' :: Monad m => ContT w m w -> m w
> > resetT' m   = runContT m return

Yes. See also
https://www.schoolofhaskell.com/user/dolio/monad-transformers-and-static-effect-scoping#an-alternate-implementation



More information about the Haskell-Cafe mailing list