Add instances for functor product#171
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.
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.
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.
Also the final . needs space around it.
Fixed in 22c80e7
There was a problem hiding this comment.
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.
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.