-
Notifications
You must be signed in to change notification settings - Fork 71
Add instances for functor product #171
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
Conversation
Control/Monad/Error/Class.hs
Outdated
|
|
||
| instance (MonadError e m, MonadError e n) => MonadError e (Product m n) where | ||
| throwError e = Pair (throwError e) (throwError e) | ||
| catchError (Pair ma na) f = Pair (catchError ma (productFst . f)) (catchError na (productSnd. f)) |
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.
Can you please write catchError in infix notation, at least on the right-hand side? It can reduce nested parentheses. Also the final . needs space around it.
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.
Can you please write catchError in infix notation, at least on the right-hand side?
When I do this:
Pair (ma `catchError` productFst . f) (na `catchError` productSnd . f)
I get a precedence parsing error (catchError is infixl 9 and . is infixr 9).
I could use infix Pair to reduce parentheses:
catchError ma (productFst . f) `Pair` catchError na (productSnd . f)
Thoughts?
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.
Also the final . needs space around it.
Fixed in 22c80e7
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.
Thoughts?
My thoughts are that my cellphone is not the best tool for collaborating on GitHub issues.
Thanks for the contribution!
mniip
left a comment
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.
A note regarding strictness: I see that all instances are strict in the Pair constructor, and I wonder whether that's correct. However I also note that the instances in base (particularly Monad) are also strict.
Closes #84
Compatibility:
Data.Functor.Productwas added totransformersin version 0.2.1, and tobasein version4.9.