Skip to content

Monomorphises all necessary strings to allow proper loading of hadrian/ghci

This MR adds type signatures and explicit list syntax for some of the string literals that prevent proper loading in ghci using Hadrian.

Prior to this patch, the following kind of compilation errors would occur when starting ./hadrian/ghci:

/home/hecate/Contrib/GHC/ghc/compiler/GHC/Utils/Misc.hs:1221:22: error:
     Could not deduce (Foldable t0) arising from a use of elem
      from the context: MonadFail m
        bound by the inferred type of
                   readExp :: MonadFail m => [Char] -> m (Int, [Char])
        at /home/hecate/Contrib/GHC/ghc/compiler/GHC/Utils/Misc.hs:(1221,6)-(1222,49)
      The type variable t0 is ambiguous
      These potential instances exist:
        instance Foldable (Either a) -- Defined in ‘Data.Foldable’
        instance Foldable Down -- Defined in ‘Data.Foldable’
        instance Foldable Proxy -- Defined in ‘Data.Foldable’
        ...plus six others
        ...plus 46 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
     In the expression: e `elem` "eE"
      In a stmt of a pattern guard for
                     an equation for readExp:
        e `elem` "eE"
      In an equation for readExp:
          readExp (e : s) | e `elem` "eE" = readExp' s
     |
1221 |      readExp (e:s) | e `elem` "eE" = readExp' s
     |                      ^^^^^^^^^^^^^


/home/hecate/Contrib/GHC/ghc/compiler/GHC/Unit/Module/Name.hs:97:55: error:
     Ambiguous type variable t0 arising from a use of elem
      prevents the constraint (Foldable t0) from being solved.
      Probable fix: use a type annotation to specify what t0 should be.
      These potential instances exist:
        instance Foldable (Either a) -- Defined in ‘Data.Foldable’
        instance Foldable Maybe -- Defined in ‘Data.Foldable’
        instance Foldable ((,) a) -- Defined in ‘Data.Foldable’
        ...plus one other
        ...plus 57 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
     In the second argument of (||), namely c `elem` "_."
      In the expression: isAlphaNum c || c `elem` "_."
      In the first argument of Parse.munch1, namely
        (\ c -> isAlphaNum c || c `elem` "_.")
   |
97 |                 $ Parse.munch1 (\c -> isAlphaNum c || c `elem` "_.")
   |                                                       ^^^^^^^^^^^^^


/home/hecate/Contrib/GHC/ghc/compiler/GHC/Unit/Parser.hs:33:45: error:
     Ambiguous type variable t0 arising from a use of elem
      prevents the constraint (Foldable t0) from being solved.
      Probable fix: use a type annotation to specify what t0 should be.
      These potential instances exist:
        instance Foldable (Either a) -- Defined in ‘Data.Foldable’
        instance Foldable GenWithIsBoot
          -- Defined at /home/hecate/Contrib/GHC/ghc/compiler/GHC/Unit/Types.hs:661:25
        instance Foldable Maybe -- Defined in ‘Data.Foldable’
        ...plus two others
        ...plus 58 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
     In the second argument of (||), namely c `elem` "-_.+"
      In the expression: isAlphaNum c || c `elem` "-_.+"
      In the first argument of Parse.munch1, namely
        (\ c -> isAlphaNum c || c `elem` "-_.+")
   |
33 |    s <- Parse.munch1 (\c -> isAlphaNum c || c `elem` "-_.+")
   |                                             ^^^^^^^^^^^^^^^

Merge request reports