Skip to content

Simplify superinstance constraints for ErrorT #18

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

Merged
merged 1 commit into from
Sep 4, 2014
Merged

Simplify superinstance constraints for ErrorT #18

merged 1 commit into from
Sep 4, 2014

Conversation

paf31
Copy link
Contributor

@paf31 paf31 commented Sep 4, 2014

@garyb @joneshf Mind having a look at this one? I'd be helpful for the latest book chapter.

This new Apply instance enables parallel asynchronous computations with ErrorT on top of a Parallel newtype for ContT which is quite nice.

@joneshf
Copy link
Member

joneshf commented Sep 4, 2014

I puzzled it for a bit, but I don't understand it. Care to elaborate?

@garyb
Copy link
Member

garyb commented Sep 4, 2014

Nice 👍

Functor m, Monad m => ... was redundant anyway, I thought I'd already gone through and updated all those after we introduced superclasses, but I guess not. I wouldn't be surprised if there are other constraints throughout transformers that can be relaxed or simplified in a similar way to this.

@paf31
Copy link
Contributor Author

paf31 commented Sep 4, 2014

@joneshf ErrorT e m a is isomorphic to m (Either e a) so if we unwrap the error constructor, we can use regular lift2 to define <*>. The problem is the extra Either e wrapper. We have an Either a (a -> b) and an Either e a and want an Either e b. We just have to lift lift2 itself. Make sense?

This is beneficial, because obviously we prefer to use the Apply instance over Monad, especially if we don't have a Monad, as is the case for Parallel in the new book chapter.

@paf31
Copy link
Contributor Author

paf31 commented Sep 4, 2014

Ok to merge then?

@joneshf
Copy link
Member

joneshf commented Sep 4, 2014

Ah, yes, go for it!

paf31 added a commit that referenced this pull request Sep 4, 2014
Simplify superinstance constraints for ErrorT
@paf31 paf31 merged commit 8de108b into master Sep 4, 2014
@paf31 paf31 deleted the errort branch September 4, 2014 22:36
@paf31
Copy link
Contributor Author

paf31 commented Sep 4, 2014

Cool, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants