-
Notifications
You must be signed in to change notification settings - Fork 65
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
General errors #177
General errors #177
Conversation
CHG: Killing a Fiber during the WAITING state defers the kill action.
CHG: Applied Nate's code cleanup suggestions.
src/Effect/Aff.purs
Outdated
|
||
-- | A monomorphic version of `try` that can map the error type. Catches thrown | ||
-- | errors and lifts them into an `Either`. | ||
attempt ∷ ∀ e1 e2 a. Aff e1 a → Aff e2 (Either e1 a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be Void
instead of e2
I suppose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aff e a
does not mean an error of type e
is definitely thrown; it means an error of type e
may be thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but if you do attempt
on some Aff computation
it must eliminate all possible errors, which means resulting Aff must throw nothing. If you stick Void
there it would mean Void may be throw
but as there is no value of type Void it means nothing can be thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would prevent you from attempt
ing inside an exiting Aff e1
, unless you lmap absurd (attempt ...)
though, which would be a bit annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general you only want to use Aff Void a
when you want to demand no exceptions from the user (taking an Aff as an argument), and use Aff void a
when you are just not using exceptions (returning an Aff), since it means you can unify with any Aff context.
backwards-compatibility API in its place.
ADD: #! operator as an alias for 'flip lmap' ADD: absurdL/absurdR for free error conversions from Void. CHG: A synchronous throw in makeAff now panics (used to throw) CHG: Made killFiber more general. CHG: Cancelers are no longer allowed to throw. CHG: Bracket finalisers are no longer allowed to throw. FIX: Handle parallel Fibers that resolve synchronously (fixes cannot call 'run' on undefined)
WIP CHG: AffResult replaces Either
…rescript-aff into general_errors
By the time I achieve what I want it is too far incompatible with the original Aff. I am instead working on a new library that builds from the lessons of Aff. I will retract both these PRs. |
Includes #169.
I expect to receive a lot of backlash over breaking backwards compatibility. What I hope is that this can start discussion about how to move forward.