Skip to content
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

Conversation

eric-corumdigital
Copy link
Contributor

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.


-- | 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)
Copy link
Contributor

@safareli safareli Aug 8, 2019

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

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 attempting inside an exiting Aff e1, unless you lmap absurd (attempt ...) though, which would be a bit annoying.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

Copy link
Collaborator

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
@eric-corumdigital
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants