Post

Surprisingly, it turns out CGP already supports fully monadic computation in Rust! It is just that the CGP monads are in the form `a -> m b` instead of the usual `m a`.

Also, the composition operator for CGP monads is not (>>=) or (>>), but rather it is just pipe (|) :: (a -> m b) -> (b -> m c) -> (a -> m c). Despite that, pipe is probably much as powerful as bind, just with different syntax.

0 reposts0 likes

Actually, the monadic form in CGP is more than just (a -> m b) - it is more like (Ctx => a -> m b). That makes it much more powerful and practical for monadic computation, because we can do dependency injection with the implicit constraints!

CGP also has the lift operator, called `Promote`, to lift the `m` in `(Ctx => a -> m b)`. With that, you can probably see how we can support everything essential about monads with CGP in Rust!