Skip to content

Misleading error message from JoinKinds  #423

@adamgundry

Description

@adamgundry

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions