You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is somewhat similar to racing but with no concurrency.
The intention is to simplify handleErrorWith/recover nesting.
I ran into this while rewritingKova.
I ended up creating a strange DSL that looks like:
or {
// first pathway
} or {
// second pathway
} or {
// third pathway
} orFail
where each or returns an Either and handles error accumulation if its input is itself an error. or Fail then simply raises the accumulated errors, and there's an or Accumulate that instead accumulates the accumulated errors
I'm not very happy with that API, though. For one, the compiler doesn't understand that conditions that result in "first pathway" raising mean that "second pathway" will run, although I'm not sure if there's a way to get that to work.
It also feels rather clunky.
With cleverer contracts, those problems would go away, sure, but it still feels inelegant.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
This is somewhat similar to
racingbut with no concurrency.The intention is to simplify
handleErrorWith/recovernesting.I ran into this while rewriting Kova.
I ended up creating a strange DSL that looks like:
where each
orreturns anEitherand handles error accumulation if its input is itself an error.or Failthen simplyraises the accumulated errors, and there's anor Accumulatethat insteadaccumulates the accumulated errorsI'm not very happy with that API, though. For one, the compiler doesn't understand that conditions that result in "first pathway" raising mean that "second pathway" will run, although I'm not sure if there's a way to get that to work.
It also feels rather clunky.
With cleverer contracts, those problems would go away, sure, but it still feels inelegant.
Beta Was this translation helpful? Give feedback.
All reactions