Skip to content

Conversation

@LightAndLight
Copy link
Contributor

Closes #84

Compatibility: Data.Functor.Product was added to transformers in version 0.2.1, and to base in version 4.9.


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

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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!

@sjshuck sjshuck merged commit da92fb9 into haskell:master Oct 25, 2025
15 checks passed
Copy link
Collaborator

@mniip mniip left a 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

instance (MonadError e f, MonadError e g) => MonadError e (Product f g)

3 participants