[Haskell-cafe] Does Backwards admit a Monad instance?

David Feuer david.feuer at gmail.com
Tue Dec 15 22:43:14 UTC 2015

I realized this does not quite satisfy the law

pure x >>= f = f x

In particular,

pure () >>= (\() -> m) :: Backwards m

is a divergent computation whenever m is a "strict" monad. Things seem
somewhat nicer when m is "lazy", but there could be further problems
I've overlooked.

On Tue, Dec 15, 2015 at 2:20 PM, David Feuer <david.feuer at gmail.com> wrote:
> In particular, I'm thinking about
> instance MonadFix m => Monad (Backwards m) where
>   m >>= f = Backwards $
>     do
>       fin <- forwards (f int)
>       int <- forwards m
>       return fin
> It looks to me like this should be valid, and compatible with the
> Applicative instance, but maybe I'm missing something.

More information about the Haskell-Cafe mailing list