"Break early" from monad CE
See original GitHub issueI have a result
CE in Cvdm.ErrorHandling for monadic error handling. For the example below, sideEffect1
and sideEffect2
are never invoked, since do!
binds an error (I think also Delay
is involved, but I don’t have a clear grasp of CE builders).
let _ = result {
if true then
do! Error err
sideEffect1 ()
sideEffect2 ()
}
However, if I replace result
with monad
(or monad.fx
or others, I’ve tried them all), the side effects are invoked.
Is it possible to get my desired behavior using a generic CE from FSharpPlus?
Issue Analytics
- State:
- Created 5 years ago
- Comments:37 (37 by maintainers)
Top Results From Across the Web
Breaking out of monad sequence - haskell
For instance, if I want to break out of a sequence earlier based on some condition calculated in the middle of the sequence....
Read more >Breaking from a loop : r/haskell
It's similar in principle to the EitherT approach in that it uses an early exit monad. However, the monad provides two ways to...
Read more >Control.Monad.Trans.Loop
LoopT is a monad transformer for the loop body. ... Break out of the loop entirely. ... Like a while loop in C,...
Read more >Add Computation Expressions (from f#) to javascript - TC39
To avoid 'breaking the web' I think async wouldn't be allowed as a custom CE builder otherwise it would change the behaviour of...
Read more >A Monad for Basic Java Semantics
Abstract This paper describes the role of a computational monad in ... all of sequential Java, including details such as exceptions, breaks, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure, in short:
1-2 It’s an early termination monadically speaking, I mean, no value will be returned afterwards, but side effects might still occur.
3-4 Async is definitely an fx monad
@cmeeren some stuff on monad transformers in F# in SO https://stackoverflow.com/questions/tagged/f%23+monad-transformers