danr / geniplate

Use TH to generate uniplate-like functions.
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

Use MIN_VERSION_template_haskell instead of __GLASGOW_HASKELL__ #6

Closed andreasabel closed 3 years ago

andreasabel commented 7 years ago
$ cabal install geniplate-mirror-0.7.4 
Resolving dependencies...
cabal: Entering directory '/tmp/cabal-tmp-28321/geniplate-mirror-0.7.4'
Configuring geniplate-mirror-0.7.4...
Building geniplate-mirror-0.7.4...
Preprocessing library geniplate-mirror-0.7.4...
[1 of 1] Compiling Data.Generics.Geniplate ( Data/Generics/Geniplate.hs, dist/build/Data/Generics/Geniplate.o )

Data/Generics/Geniplate.hs:84:25:
    Couldn't match expected type ‘Dec’ with actual type ‘[Dec] -> Dec’
    Probable cause: ‘InstanceD’ is applied to too few arguments
    In the expression:
      InstanceD [] (foldl AppT (ConT cls) ts) (funDef met e)
    In the expression:
      [InstanceD [] (foldl AppT (ConT cls) ts) (funDef met e)]

Data/Generics/Geniplate.hs:84:35:
    Couldn't match expected type ‘Maybe Overlap’
                with actual type ‘[t0]’
    In the first argument of ‘InstanceD’, namely ‘[]’
    In the expression:
      InstanceD [] (foldl AppT (ConT cls) ts) (funDef met e)
    In the expression:
      [InstanceD [] (foldl AppT (ConT cls) ts) (funDef met e)]

Data/Generics/Geniplate.hs:84:45:
    Couldn't match type ‘Type’ with ‘[Pred]’
    Expected type: Cxt -> Type -> Cxt
      Actual type: Type -> Type -> Type
    In the first argument of ‘foldl’, namely ‘AppT’
    In the second argument of ‘InstanceD’, namely
      ‘(foldl AppT (ConT cls) ts)’

Data/Generics/Geniplate.hs:84:51:
    Couldn't match type ‘Type’ with ‘[Pred]’
    Expected type: Cxt
      Actual type: Type
    In the second argument of ‘foldl’, namely ‘(ConT cls)’
    In the second argument of ‘InstanceD’, namely
      ‘(foldl AppT (ConT cls) ts)’

Data/Generics/Geniplate.hs:84:66:
    Couldn't match expected type ‘Type’ with actual type ‘[Dec]’
    In the third argument of ‘InstanceD’, namely ‘(funDef met e)’
    In the expression:
      InstanceD [] (foldl AppT (ConT cls) ts) (funDef met e)

Data/Generics/Geniplate.hs:404:17:
    Constructor ‘DataD’ should have 6 arguments, but has been given 5
    In the pattern: DataD _ _ tvs cs _
    In the pattern: TyConI (DataD _ _ tvs cs _)
    In a case alternative:
        TyConI (DataD _ _ tvs cs _) -> return (tvs, cs)

Data/Generics/Geniplate.hs:428:9:
    Constructor ‘VarI’ should have 3 arguments, but has been given 4
    In the pattern: VarI _ t _ _
    In a case alternative: VarI _ t _ _ -> splitType t
    In a stmt of a 'do' block:
      case info of {
        VarI _ t _ _ -> splitType t
        _ -> genError $ "Name is not variable: " ++ pprint name }
cabal: Leaving directory '/tmp/cabal-tmp-28321/geniplate-mirror-0.7.4'
Failed to install geniplate-mirror-0.7.4
asr commented 7 years ago

@andreasabel, Can you fix the problem by running

cabal install --constraint=template-haskell==2.9.0.0 geniplate-mirror

?

I guess geniplate-mirror must use the version of template-haskell shipped with the version of GHC used for installing this library. So how, compiling https://github.com/agda/agda/commit/749319f5eff3af8d86ed0c0886543de7a04088db with GCH 7.8.4 requires install a lot new versions of different libraries including template-haskell.

andreasabel commented 7 years ago

No, this does not work:

$ cabal install --constraint=template-haskell==2.9.0.0 geniplate-mirror

Resolving dependencies...
cabal: Entering directory '/tmp/cabal-tmp-31124/geniplate-mirror-0.7.4'
Configuring geniplate-mirror-0.7.4...
Building geniplate-mirror-0.7.4...
Preprocessing library geniplate-mirror-0.7.4...
[1 of 1] Compiling Data.Generics.Geniplate ( Data/Generics/Geniplate.hs, dist/build/Data/Generics/Geniplate.o )

Data/Generics/Geniplate.hs:17:1:
    Bad interface file: /usr/local/lib/ghc-7.8.4/template-haskell-2.9.0.0/Language/Haskell/TH.hi
        Something is amiss; requested module  template-haskell-2.9.0.0:Language.Haskell.TH differs from name found in the interface file template-haskell:Language.Haskell.TH

Data/Generics/Geniplate.hs:18:1:
    Bad interface file: /usr/local/lib/ghc-7.8.4/template-haskell-2.9.0.0/Language/Haskell/TH/Syntax.hi
        Something is amiss; requested module  template-haskell-2.9.0.0:Language.Haskell.TH.Syntax differs from name found in the interface file template-haskell:Language.Haskell.TH.Syntax
cabal: Leaving directory '/tmp/cabal-tmp-31124/geniplate-mirror-0.7.4'
Failed to install geniplate-mirror-0.7.4
cabal: Error: some packages failed to install:
geniplate-mirror-0.7.4 failed during the building phase. The exception was:
ExitFailure 1
asr commented 7 years ago
Data/Generics/Geniplate.hs:17:1:
    Bad interface file: /usr/local/lib/ghc-7.8.4/template-haskell-2.9.0.0/Language/Haskell/TH.hi
        Something is amiss; requested module  template-haskell-2.9.0.0:Language.Haskell.TH differs from name found in the interface file template-haskell:Language.Haskell.TH

The above error is weird. template-haskell-2.9.0.0 is the version shipped with GHC 7.8.4. Does ghc-pkg report to broken this version of template-haskell?

asr commented 7 years ago

Which is (without the haddock warnings) the output of ghc-pkg check?

andreasabel commented 7 years ago

This is the output:

There are problems in package Agda-2.5.2:
  dependency "EdisonCore-1.3.1.1-e3515e864bd50544657c421ab985e768" doesn't exist
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "gitrev-1.2.0-HKbRJLszjJsJe5vFcWzO9Y" doesn't exist
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package Agda-2.6.0:
  dependency "EdisonCore-1.3.1.1-e3515e864bd50544657c421ab985e768" doesn't exist
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "gitrev-1.2.0-HKbRJLszjJsJe5vFcWzO9Y" doesn't exist
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package tasty-rerun-1.1.6:
  dependency "tasty-0.11.0.4-IGLKjSd58nE7og9S5VTU7L" doesn't exist
There are problems in package tasty-golden-2.3.1.1:
  dependency "tasty-0.11.0.4-IGLKjSd58nE7og9S5VTU7L" doesn't exist
  dependency "temporary-1.2.0.4-LmRtKLaBYIE12Bw0nIfO4I" doesn't exist
There are problems in package Agda-2.5.1.1:
  dependency "EdisonCore-1.3.1.1-e3515e864bd50544657c421ab985e768" doesn't exist
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package graphviz-2999.18.1.2:
  dependency "temporary-1.2.0.4-LmRtKLaBYIE12Bw0nIfO4I" doesn't exist
There are problems in package conduit-1.2.7:
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package lens-4.14:
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package adjunctions-4.2.2:
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package wai-extra-3.0.15.1:
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package contravariant-1.4:
  dependency "void-0.7.1-88b9aa134b3d622fa67b0f57e289dfca" doesn't exist
There are problems in package tog-0.1.0:
  dependency "bifunctors-5.2-7451e7c413a68487b921114102bf668b" doesn't exist
  dependency "profunctors-5.2-a5bd0aca88a2d55ccfa06d2f54945567" doesn't exist
There are problems in package lens-4.13.2.1:
  dependency "bifunctors-5.2-7451e7c413a68487b921114102bf668b" doesn't exist
  dependency "comonad-4.2.7.2-34bfbe810272ce32abf0e06cb620a3ae" doesn't exist
  dependency "contravariant-1.4-f18803adcc281bad82e14cf04a8cf9a3" doesn't exist
  dependency "free-4.12.4-ccd363fe26ddcf6cc0d977fad83bfc04" doesn't exist
  dependency "kan-extensions-5.0.1-39576b084f109f870568681bb22c1811" doesn't exist
  dependency "profunctors-5.2-a5bd0aca88a2d55ccfa06d2f54945567" doesn't exist
  dependency "semigroupoids-5.0.1-c2b45917c50ad22f77b9d03d8ebea45d" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
There are problems in package either-4.4.1:
  dependency "bifunctors-5.2-7451e7c413a68487b921114102bf668b" doesn't exist
  dependency "free-4.12.4-ccd363fe26ddcf6cc0d977fad83bfc04" doesn't exist
  dependency "profunctors-5.2-a5bd0aca88a2d55ccfa06d2f54945567" doesn't exist
  dependency "semigroupoids-5.0.1-c2b45917c50ad22f77b9d03d8ebea45d" doesn't exist
There are problems in package Agda-2.4.2.6:
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
There are problems in package Agda-2.5.0:
  dependency "EdisonCore-1.3.1.1-e3515e864bd50544657c421ab985e768" doesn't exist
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
There are problems in package Agda-2.5:
  dependency "EdisonCore-1.3.1.1-e3515e864bd50544657c421ab985e768" doesn't exist
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
There are problems in package Agda-2.4.2.5:
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
Warning: include-dirs: /usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 doesn't exist or isn't a directory
There are problems in package Agda-2.4.3:
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
  dependency "void-0.7.1-7fc0def66fd7a96838b50e35002f844b" doesn't exist
There are problems in package Agda-2.4.2.4:
  dependency "equivalence-0.3.1-a116a8fd678c013594ca4d2872891f21" doesn't exist
There are problems in package lens-4.11:
  dependency "bifunctors-5-822bc05ab85b4552a84ffb4406e9e371" doesn't exist
  dependency "text-1.2.1.1-57a6504f5a1a516fd3475dfc7ca930a3" doesn't exist
  dependency "unordered-containers-0.2.5.1-7e8352a3610fb077deedb213c4060fef" doesn't exist
There are problems in package free-4.12.1:
  dependency "bifunctors-5-822bc05ab85b4552a84ffb4406e9e371" doesn't exist
There are problems in package semigroupoids-5.0.0.2:
  dependency "bifunctors-5-822bc05ab85b4552a84ffb4406e9e371" doesn't exist
There are problems in package semigroups-0.16.2.2:
  dependency "nats-1-bfb955929fd4ca96ff42e7d64d9334f8" doesn't exist
  dependency "text-1.2.1.1-57a6504f5a1a516fd3475dfc7ca930a3" doesn't exist
  dependency "unordered-containers-0.2.5.1-7e8352a3610fb077deedb213c4060fef" doesn't exist
There are problems in package hashable-1.2.3.2:
  dependency "text-1.2.1.1-57a6504f5a1a516fd3475dfc7ca930a3" doesn't exist

The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
Agda-2.5.2
Agda-2.6.0
tasty-rerun-1.1.6
tasty-golden-2.3.1.1
Agda-2.5.1.1
graphviz-2999.18.1.2
conduit-1.2.7
lens-4.14
adjunctions-4.2.2
wai-extra-3.0.15.1
contravariant-1.4
tog-0.1.0
lens-4.13.2.1
either-4.4.1
Agda-2.4.2.6
Agda-2.5.0
Agda-2.5
Agda-2.4.2.5
Agda-2.4.3
Agda-2.4.2.4
lens-4.11
free-4.12.1
semigroupoids-5.0.0.2
semigroups-0.16.2.2
hashable-1.2.3.2
trifecta-1.6
darcs-2.12.0
sandi-0.3.6
idris-0.11.2
trifecta-1.5.2
kan-extensions-5.0.1
reducers-3.12.1
free-4.12.4
semigroupoids-5.0.1
profunctors-5.2
bifunctors-5.2
comonad-4.2.7.2
kan-extensions-4.2.2
adjunctions-4.2.1
profunctors-5.1.1
comonad-4.2.6
contravariant-1.3.1.1
void-0.7
andreasabel commented 7 years ago

After unregistering all these broken packages, nothing has changed. I get the same error if I constrain template-haskell in the way you described above.

danr commented 7 years ago

This is really weird. Supposedly 7.8.4 should have template-haskell 2.9.0.0, and for instance (hehe) InstanceD should have three arguments, not four as in later versions: https://downloads.haskell.org/~ghc/7.8.4/docs/html/libraries/template-haskell-2.9.0.0/Language-Haskell-TH.html#v:InstanceD

On 14 December 2016 at 09:47, Andreas Abel notifications@github.com wrote:

After unregistering all these broken packages, nothing has changed. I get the same error if I constrain template-haskell in the way you described above.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danr/geniplate/issues/6#issuecomment-266976831, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMK1DNNKq-rVazF9ZKAzGpjRAtMk-3fks5rH60UgaJpZM4LL4wk .

andreasabel commented 7 years ago

I could only fix this by manually unregistering the alien template-haskell version:

$ ghc-pkg list | grep template
    template-haskell-2.9.0.0
    template-haskell-2.11.0.0
$ ghc-pkg unregister template-haskell-2.11.0.0

Thus, in the end, this is a bug in ghc and its handling of packages.

For one, I don't know why ghc would even let another version of template-haskell be installed, if it can only work with one version. Then, it gets confused by the two versions, probably because it relies on the invariant that there is only one, or whatever.

nick8325 commented 7 years ago

Oh, I think I know what this is; we had the same problem in QuickCheck.

Despite what you might expect, the template-haskell package is upgradeable, i.e., it's not tied to a specific version of GHC - you can have an older GHC with a newer TH. However, geniplate uses the GHC version to decide which version of the TH code to include:

#if __GLASGOW_HASKELL__ <= 710
... implementation for old TH here ...
#else
... implementation for new TH here ...
#endif

Hopefully it will work if all the #ifs are changed to use MIN_VERSION_template_haskell instead.