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

Misleading error message from JoinKinds #423

Closed
adamgundry opened this issue Jun 8, 2021 · 3 comments · Fixed by #439 · May be fixed by #424
Closed

Misleading error message from JoinKinds #423

adamgundry opened this issue Jun 8, 2021 · 3 comments · Fixed by #439 · May be fixed by #424

Comments

@adamgundry
Copy link
Member

With 0.4 and current HEAD:

ghci> :t castOptic @A_Setter @A_Setter (traversed % _1)

<interactive>:1:42: error:
    • A_Traversal cannot be composed with A_Lens
    • In the third argument of ‘castOptic’, namely ‘(traversed % _1)’
      In the expression: castOptic @A_Setter @A_Setter (traversed % _1)

Oops! I think what is going on here is that we get a constraint JoinKinds A_Traversal A_Lens A_Setter which of course does not match the instance JoinKinds A_Traversal A_Lens A_Traversal, so the catch-all error instance fires. Ideally we would have two different errors, one for "this composition doesn't make sense" and another for "this composition makes sense, but produces an optic of a different kind to that expected by the context".

@dminuoso
Copy link

dminuoso commented Dec 6, 2021

I managed to provoke this version of an error:

• An_AffineTraversal cannot be composed with An_AffineTraversal

Even more confusing to the unsuspecting.

@arybczak
Copy link
Collaborator

arybczak commented Dec 6, 2021

Uh. @dminuoso do you have a reproducer? If not, can you please check if the situation is improved by #439?

@dminuoso
Copy link

dminuoso commented Dec 6, 2021

This trivially reproduces the diagnostic:

> united % united :: AffineFold () ()

<interactive>:13:1: error:
    • A_Lens cannot be composed with A_Lens
    • In the expression: united % united :: AffineFold () ()
      In an equation for ‘it’: it = united % united :: AffineFold () ()

With #439 I get:

> united % united :: AffineFold () ()

<interactive>:3:1: error:
    • Couldn't match type ‘An_AffineFold’ with ‘A_Lens’
        arising from a use of ‘%’
    • In the expression: united % united :: AffineFold () ()
      In an equation for ‘it’: it = united % united :: AffineFold () ()

which is a huge improvement. :)

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