-
First of all congrats for the work here it's literally fantastic. I haven't found an answer to my issue so here it goes. I would like to somehow "keep tabs" of the Errors produced in some kind of sequence without the computation hard stopping like it does with a (example from wiki) var numberV = DigitsOnly(number) | MaxStrLength(16)(number); Following another example from wiki we see the following piece of code. static Eff<RT, Unit> askUser =>
repeat(from ln in Console<RT>.readLine
from _1 in guard(notEmpty(ln), UserExited)
from _2 in guardnot(ln == "sys", () => throw new SystemException())
from _3 in guardnot(ln == "err", () => throw new Exception())
from _4 in Console<RT>.writeLine(ln)
select unit)
| @catch(UserExited, unit); How is it possible to keep repeating the computation if for example the line is empty - and thus ask again for more input - but without handling it immediately with a PS: Of course maybe the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Monadic operations force an order, and must exit as soon as there's an error. If you think about it it's obvious: from x in broken
from y in working
select x + y; Clearly we can't have a situation where The way to achieve capture of multiple errors is to use applicatives, which are independent terms in an expression. Those independent terms can all be run and all errors collected, but it's a bit more awkward to do with C#. I have just added support for a multi-error It's a bit late here now, and I'll admit to having not fully read your request properly yet. However It might be worth having a read of the release notes to see if it helps you. |
Beta Was this translation helpful? Give feedback.
-
@louthy After a lot of pondering and soul searching what I am really going after, I believe you brought all the pieces to play by adding applicative behavior of from _1 in askUser
| @catch(ex => ex is SystemException, err => { return SuccessAff<RT, (ManyErrors, int)>(combineTuples((err, 0), _prevComp); })
from _2 in Console<RT>.writeLine("goodbye") where I am marking it as answer. |
Beta Was this translation helpful? Give feedback.
Monadic operations force an order, and must exit as soon as there's an error. If you think about it it's obvious:
Clearly we can't have a situation where
broken
fails and then leavesx
in an uninitialised state.The way to achieve capture of multiple errors is to use applicatives, which are independent terms in an expression. Those independent terms can all be run and all errors collected, but it's a bit more awkward to do with C#.
I have just added support for a multi-error
Error
type, and applicative functor support toAff
andEff
.It's a bit late here now, and I'll admit to having not fully read your request properly yet. How…