Patch `ghc-tcplugins-extra`, `ghc-typelits-extra`, and friends to build with GHC HEAD
After ghc@d603f199 (ghc!12037 (closed)), ghc-tcplugins-extra
fails to build with head.hackage
+ GHC HEAD, as seen in this failing CI job:
Building library for ghc-tcplugins-extra-0.4.5..
[1 of 8] Compiling GhcApi.Constraint
[2 of 8] Compiling GhcApi.GhcPlugins
src-ghc-9.8/GhcApi/GhcPlugins.hs:3:38: warning: [GHC-61689] [-Wdodgy-imports]
Module ‘GHC.Plugins’ does not export ‘mkSubst’.
|
3 | import GHC.Plugins hiding (TcPlugin, mkSubst)
| ^^^^^^^
[3 of 8] Compiling GhcApi.Predicate
[4 of 8] Compiling Internal.Constraint
[5 of 8] Compiling Internal.Evidence
src-ghc-9.8/Internal/Evidence.hs:14:33: error: [GHC-83865]
• Couldn't match expected type ‘UnivCoProvenance’
with actual type ‘DCoVarSet -> UnivCoProvenance’
• Probable cause: ‘PluginProv’ is applied to too few arguments
In the first argument of ‘mkUnivCo’, namely ‘(PluginProv name)’
In the second argument of ‘($)’, namely
‘mkUnivCo (PluginProv name) Nominal t1 t2’
In the second argument of ‘($)’, namely
‘Coercion $ mkUnivCo (PluginProv name) Nominal t1 t2’
|
14 | EvExpr $ Coercion $ mkUnivCo (PluginProv name) Nominal t1 t2
| ^^^^^^^^^^^^^^^
[6 of 8] Compiling Internal.Type
Error: cabal: Failed to build ghc-tcplugins-extra-0.4.5 (which is required by
test-ghc-tcplugins-extra-1.0). See the build log above for details.
Most likely, we will need to fix this by adding a DCoVarSet
argument to the evByFiat
function (whose implementation is shown in the error message). However, that is only part of the battle, as evByFiat
is used here in ghc-typelits-extra
(and possibly other packages—I haven't checked thoroughly). We will need to patch ghc-typelits-extra
and friends to supply an appropriate DCoVarSet
whenever evByFiat
is called.
Speaking of which, what is an appropriate DCoVarSet
to pass here? My understanding of ghc!12037 (closed) is that if the plugin interacts with Given constraints (and I believe ghc-typelits-extra
is one such plugin), then the DCoVarSet
will need to contain the coercion variables used in the Given constraints. That being said, I am not familiar with the implementation of ghc-typelits-extra
, so I am not sure what the most appropriate way of computing the Given constraints' coercion variables will be.
For the sake of getting the CI on the head.hackage
repo to pass, I will temporarily allow ghc-tcplugins-extra
and its reverse dependencies to fail building. We should really look into how to fix this properly, however.