No, that is not true; the laws of the monad are, at best, preserved in some approximate form. As Peter Pudlak’s answer shows, Backwards m >>= f doesn’t look very good when f is strict in its argument.
According to the laws of the monad,
pure () >>= (\() -> m) = m
But with this case, if I’m not mistaken,
pure () >>= (\() -> m) = Backwards $ do fin <- forwards (int `seq` m) int <- pure () pure fin = Backwards $ fmap fst $ mfix $ \ ~(_, int) -> do fin <- forwards (int `seq` m) pure (fin, ())
If the main monad is "strict" (that is, its >>= strictly in the left operand), this will diverge.
dfeuer
source share