question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Break early" from monad CE

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:37 (37 by maintainers)

github_iconTop GitHub Comments

2reactions
gustycommented, Nov 7, 2018

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

2reactions
gustycommented, Nov 2, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found