frasertweedale / hs-jose

Haskell JOSE and JWT library
http://hackage.haskell.org/package/jose
Apache License 2.0
122 stars 46 forks source link

OverlappingInstances in simple ValidationSettings usage #81

Closed cbeav closed 2 years ago

cbeav commented 5 years ago

Trying to do a simple JWT validation, and looking to use the AnyValidated policy. Here's what I've got:

    validation :: ValidationSettings
    validation = defaultValidationSettings & validationPolicy .~ AnyValidated

Simple enough. But the instance definitions for HasValidationSettings are giving me some trouble:

    • Overlapping instances for HasValidationSettings
                                  ValidationSettings
        arising from a use of ‘validationPolicy’
      Matching instances:
        instance HasJWTValidationSettings a => HasValidationSettings a
          -- Defined in ‘Crypto.JWT’
        instance HasValidationSettings ValidationSettings
          -- Defined in ‘Crypto.JOSE.JWS’
    • In the first argument of ‘(.~)’, namely ‘validationPolicy’
      In the second argument of ‘(&)’, namely
        ‘validationPolicy .~ AnyValidated’
      In the expression:
        defaultValidationSettings & validationPolicy .~ AnyValidated
   |
30 |     validation = defaultValidationSettings & validationPolicy .~ AnyValidated
   |                                              ^^^^^^^^^^^^^^^^

This isn't a pattern I've seen before. Is there some trick to disambiguating the instances (exported from the same module), or am I missing something more basic here. Much appreciated!

cbeav commented 5 years ago

For now, I've move the Crypto.JOSE.JWS logic into its own file, to disambiguate the instances. But the problem still remains that I'm not sure how the instance in Crypto.JWT would ever be used if needed :)

frasertweedale commented 2 years ago

I believe that 49c327e604df98b66d8510387f6dfe6e4f54e811 has resolved this issue. If not, please re-open and include code that demonstrates the problem. Thanks!