Nathan Bedell
10/06/2021, 3:27 PMSequence
monad (which I think would be similar to the List monad in Haskell), or any other similar non-deterministic monad using Arrow-style comprehension notation using coroutines?
I know there are examples of "result type" comprehensions in arrow core (e.x. Either
), and I've been able on my own to figure out how to build a monad comprehension syntax for a ReaderT IO
-like monad (this was actually pretty easy) -- but I can't for the life of me figure out how to encode a non-deterministic monad like Sequence
using the methods of Arrow.
Has anyone attempted this, or have any working examples? As I understand, the problem is basically to encode the monad as a sub-monad of the continuation monad (i.e the whole "continuations are the mother of all monads" thing) -- but I'm not experienced enough with continuations be able to grok that yet.Jannis
10/06/2021, 4:02 PMJannis
10/06/2021, 4:03 PMJannis
10/06/2021, 4:03 PMNathan Bedell
10/06/2021, 5:14 PMSequence
monad, but still interesting.Jannis
10/06/2021, 5:17 PMNathan Bedell
10/06/2021, 5:18 PMFree
, but for a concrete instance of a free monad, would it be possible to implement it via coroutines keeping within the one-shot restriction?
If so, it seems to me like that might be another workaround -- encode some "non-deterministic" methods like choose: (List<A>) -> M<A>
in your free monad, build up your Free
instance with coroutines, and then interpret those methods in terms of the methods of the "actual" non-deterministic monad in question.Nathan Bedell
10/06/2021, 5:19 PM