well-typed / large-records

Library to support efficient compilation of large records (linear in the number of record fields)
44 stars 21 forks source link

Compilation errors with Stack LTS 18.28 #157

Closed saurabhnanda closed 5 months ago

saurabhnanda commented 5 months ago

I'm running into the following error when trying to compile large-anon with the following settings:

large-anon> /tmp/stack-db465e1d7b4a9553/large-anon-0.3.0/src/Data/Record/Anon/Internal/Plugin/TC/TyConSubst.hs:315:11: error:
large-anon>     • No instance for (Outputable
large-anon>                          (Map TcTyVar (NonEmpty (TyCon, [Type]))))
large-anon>         arising from a use of ‘ppr’
large-anon>       There are instances for similar types:
large-anon>         instance (Outputable key, Outputable elt) =>
large-anon>                  Outputable (containers-0.6.5.1:Data.Map.Internal.Map key elt)
large-anon>           -- Defined in ‘Outputable’
large-anon>     • In the second argument of ‘(<+>)’, namely ‘ppr tyConSubstMap’
large-anon>       In the first argument of ‘(<+>)’, namely
large-anon>         ‘text "TyConSubst" <+> ppr tyConSubstMap’
large-anon>       In the second argument of ‘($)’, namely
large-anon>         ‘text "TyConSubst" <+> ppr tyConSubstMap <+> ppr tyConSubstCanon’
large-anon>     |
large-anon> 315 |       <+> ppr tyConSubstMap
large-anon>     |           ^^^^^^^^^^^^^^^^^
large-anon> 
large-anon> /tmp/stack-db465e1d7b4a9553/large-anon-0.3.0/src/Data/Record/Anon/Internal/Plugin/TC/TyConSubst.hs:316:11: error:
large-anon>     • No instance for (Outputable (Map TcTyVar TcTyVar))
large-anon>         arising from a use of ‘ppr’
large-anon>       There are instances for similar types:
large-anon>         instance (Outputable key, Outputable elt) =>
large-anon>                  Outputable (containers-0.6.5.1:Data.Map.Internal.Map key elt)
large-anon>           -- Defined in ‘Outputable’
large-anon>     • In the second argument of ‘(<+>)’, namely ‘ppr tyConSubstCanon’
large-anon>       In the second argument of ‘($)’, namely
large-anon>         ‘text "TyConSubst" <+> ppr tyConSubstMap <+> ppr tyConSubstCanon’
large-anon>       In the expression:
large-anon>         parens
large-anon>           $ text "TyConSubst" <+> ppr tyConSubstMap <+> ppr tyConSubstCanon
large-anon>     |
large-anon> 316 |       <+> ppr tyConSubstCanon
large-anon>     |           ^^^^^^^^^^^^^^^^^^^
large-anon> 
large-anon> <no location info>: warning: [-Wunused-packages]
large-anon>     The following packages were specified via -package or -package-id flags,
large-anon>     but were not needed for compilation:
large-anon>       - typelet-0.1.3
large-anon>       - tagged-0.8.6.1
large-anon>       - sop-core-0.5.0.2
large-anon>       - record-hasfield-1.0
large-anon>       - primitive-0.7.3.0
large-anon>       - optics-core-0.3.0.1
large-anon>       - large-generics-0.2.1
large-anon>       - deepseq-1.4.4.0
large-anon>       - aeson-1.5.6.0
large-anon> 
edsko commented 5 months ago

I reproduced this, and took a loook at what's happening. I think the problem is that you are specifying containers-0.6.8, but the stack resolver you are using is LTS 18.28, which is based on ghc 8.10.7. This is problematic, because containers is a boot library; specifically, ghc (as API, a dependency of large-anon) is built against containers-0.6.5.1; by specifying that you want a different version of containers, you essentially end up with two versions of the types defined in containers, one from containers-0.6.5.1 (which ghc is linked against) and one from your explicit dependencies. The error message you are getting is (I think) because it's using Map from containers-0.6.8 but ghc only defines Outputable instances for Map from containers-0.6.5.1. Generally, using multiple versions of the same package in one build is not something that the Haskell build tools can deal with very well.

If you drop the version override on containers the problem goes away.

Hope that helps! :)