-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monads for nested #3113
Comments
Related: #1478 |
The problem is that the resulting monads might not actually be lawful and we generally don't want unlawful instances |
Not guaranteed to be a lawful |
Thanks! ah I see. well that's a shame. :) It doesn't look like the other implementation has been looked at in that PR. I'd be curious to know if the other one would violate the exact same set of laws or a different set. |
I suspect it would have the same problem. Ultimately, what this comes down to is the fact that effect sequencing is a fundamentally non-general problem. Some random examples:
Each of these effects has a different strategy for composing over other effects. Monad transformers as a mechanism allow this to be handled because each transformer is fundamentally tied to the specific type layer under composition. More general mechanisms such as this one attempt to compose arbitrary Some prior art:
|
For a certain catagory of monads, we can have a monad for their composition.
and
Being able to compose those class of monads "for free" is quite useful. What do people think about providing this composition for
Nested
? We could of course provide the said requirements on F & G through separate intermediary types and use those instead ofNested
.Fyi, This came up in my attempt at implementing
Parallel
instances for nested structures. but obviously it allows us to do flatmaps on nested structures so it's quite useful for cases that are not easily addressed for simpleEitherT
orOptionT
s.The text was updated successfully, but these errors were encountered: