well-typed / optics

Optics as an abstract interface
374 stars 24 forks source link

Support GHC 9.6 #477

Closed adamgundry closed 1 year ago

adamgundry commented 1 year ago

It would be good to bump bounds to support GHC 9.6. We may need to wait for this issue to be resolved, which hopefully it will be before the release: https://gitlab.haskell.org/ghc/ghc/-/issues/22821

That also unlocks the possibility to use uppercase OverloadedLabels, so we could look at supporting those for prisms instead of the _ prefix hack.

TeofilC commented 1 year ago

FWIW I think you can work around that issue by removing OverloadedLabels from default-extensions in all the cabal files.

Everything except optics-sop seems to build. It fails with this message:

Show error ``` src/Optics/SOP.hs:58:24: error: [GHC-05617] • Could not deduce ‘Code s1 ~ '[xs4]’ arising from a use of ‘productRep’ from the context: IsProductType a xs bound by the type signature for: lenses :: forall a (xs :: [*]). IsProductType a xs => NP (WrappedLens a) xs at src/Optics/SOP.hs:(55,1)-(57,47) The type variable ‘s1’ is ambiguous • In the expression: productRep In the first argument of ‘coerce’, namely ‘(productRep %)’ In the first argument of ‘hmap’, namely ‘(coerce (productRep %))’ | 58 | lenses = hmap (coerce (productRep %)) (go sList) | ^^^^^^^^^^ src/Optics/SOP.hs:62:16: error: [GHC-18872] • Couldn't match representation of type: Optic A_Lens NoIx (NP I (x : xs5)) (NP I (x : xs5)) x x with that of: Optic A_Lens '[] (NP I (a3 : xs2)) (NP I (b2 : xs2)) a3 b2 arising from a use of ‘coerce’ The data constructor ‘Optics.Internal.Optic.Optic’ of newtype ‘Optic’ is not in scope • In the first argument of ‘(:*)’, namely ‘coerce (npHead % _I)’ In the expression: coerce (npHead % _I) :* hmap (coerce (npTail %)) (go sList) In an equation for ‘go’: go SCons = coerce (npHead % _I) :* hmap (coerce (npTail %)) (go sList) | 62 | go SCons = coerce (npHead % _I) :* hmap (coerce (npTail %)) (go sList) | ^^^^^^ src/Optics/SOP.hs:62:46: error: [GHC-18872] • Couldn't match representation of type: Optic A_Lens NoIx (NP I (x : xs5)) (NP I (x : xs5)) a6 a6 with that of: Optic m2 ks2 (NP f2 (x2 : xs3)) (NP f2 (x2 : ys1)) a4 b3 arising from a use of ‘coerce’ The data constructor ‘Optics.Internal.Optic.Optic’ of newtype ‘Optic’ is not in scope • In the first argument of ‘hmap’, namely ‘(coerce (npTail %))’ In the second argument of ‘(:*)’, namely ‘hmap (coerce (npTail %)) (go sList)’ In the expression: coerce (npHead % _I) :* hmap (coerce (npTail %)) (go sList) | 62 | go SCons = coerce (npHead % _I) :* hmap (coerce (npTail %)) (go sList) | ^^^^^^ src/Optics/SOP.hs:72:18: error: [GHC-18872] • Couldn't match representation of type: Optic A_Prism NoIx a a (NP I a6) (NP I a6) with that of: Optic m1 ks1 s0 t0 a2 b1 arising from a use of ‘coerce’ The data constructor ‘Optics.Internal.Optic.Optic’ of newtype ‘Optic’ is not in scope • In the first argument of ‘hmap’, namely ‘(coerce ((rep % sop) %))’ In the expression: hmap (coerce ((rep % sop) %)) (go sList) In an equation for ‘npPrisms’: npPrisms = hmap (coerce ((rep % sop) %)) (go sList) where go :: forall yss. SList yss -> NP (WrappedNPPrism (NS (NP I) yss)) yss go SNil = Nil go SCons = coerce _Z :* hmap (coerce (_S %)) (go sList) • Relevant bindings include npPrisms :: NP (WrappedNPPrism a) xss (bound at src/Optics/SOP.hs:72:1) | 72 | npPrisms = hmap (coerce ((rep % sop) %)) (go sList) | ^^^^^^ src/Optics/SOP.hs:76:16: error: [GHC-18872] • Couldn't match representation of type: Optic A_Prism NoIx (NS (NP I) (x : xs)) (NS (NP I) (x : xs)) (NP I x) (NP I x) with that of: Optic A_Prism NoIx (NS f0 (x0 : xs0)) (NS f0 (y0 : xs0)) (f0 x0) (f0 y0) arising from a use of ‘coerce’ The data constructor ‘Optics.Internal.Optic.Optic’ of newtype ‘Optic’ is not in scope • In the first argument of ‘(:*)’, namely ‘coerce _Z’ In the expression: coerce _Z :* hmap (coerce (_S %)) (go sList) In an equation for ‘go’: go SCons = coerce _Z :* hmap (coerce (_S %)) (go sList) | 76 | go SCons = coerce _Z :* hmap (coerce (_S %)) (go sList) | ^^^^^^ src/Optics/SOP.hs:76:35: error: [GHC-18872] • Couldn't match representation of type: Optic A_Prism NoIx (NS (NP I) (x : xs)) (NS (NP I) (x : xs)) (NP I a6) (NP I a6) with that of: Optic m0 ks0 (NS f1 (x1 : xs1)) (NS f1 (x1 : ys0)) a1 b0 arising from a use of ‘coerce’ The data constructor ‘Optics.Internal.Optic.Optic’ of newtype ‘Optic’ is not in scope • In the first argument of ‘hmap’, namely ‘(coerce (_S %))’ In the second argument of ‘(:*)’, namely ‘hmap (coerce (_S %)) (go sList)’ In the expression: coerce _Z :* hmap (coerce (_S %)) (go sList) | 76 | go SCons = coerce _Z :* hmap (coerce (_S %)) (go sList) | ^^^^^^ ```
phadej commented 1 year ago

FWIW, I'll be happy to just remove optics-sop from cabal.project. AFAIK there is no plans to release it any time soon, and even if were on the radar, I'd say it should be in separate repository.

phadej commented 1 year ago

Done in #480

ysangkok commented 1 year ago

It would be nice with a release such that people don't need to use source-repository-project. But not urgent.

arybczak commented 1 year ago

@ysangkok I updated bounds of optics-th with a revision, that should be enough.