Closed
Description
Describe the bug
Loading Cabal library into repl is harder than it could be.
To Reproduce
Steps to reproduce the behavior:
% git log -n1 | cat
commit 50d59cfc82fad32f2c708339a083b48a1c36dc30
Merge: 120e5394a bf66f07dc
Author: Oleg Grenrus <oleg.grenrus@iki.fi>
Date: Fri May 22 20:50:55 2020 +0300
Merge pull request #6831 from phadej/fix-windows-gh-actions
Fix Windows GitHub Action
% cabal --version
cabal-install version 3.3.0.0
compiled using version 3.3.0.0 of the Cabal library
% pwd
/home/greg/s/cabal/Cabal
% cabal v2-repl
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
- Cabal-3.3.0.0 (lib) (first run)
Preprocessing library for Cabal-3.3.0.0..
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/greg/.ghci
[ 1 of 245] Compiling Distribution.Compat.Async ( Distribution/Compat/Async.hs, interpreted )
...
[ 80 of 245] Compiling Distribution.Types.ComponentId ( Distribution/Types/ComponentId.hs, interpreted )
Distribution/Types/ComponentId.hs:66:39: error:
• Could not deduce (Foldable t0) arising from a use of ‘elem’
from the context: CabalParsing m
bound by the type signature for:
parsec :: forall (m :: * -> *). CabalParsing m => m ComponentId
at Distribution/Types/ComponentId.hs:65:3-8
The type variable ‘t0’ is ambiguous
These potential instances exist:
instance Foldable NonEmptySet
-- Defined at Distribution/Compat/NonEmptySet.hs:71:10
instance Foldable (Either a) -- Defined in ‘Data.Foldable’
instance Foldable Identity -- Defined in ‘Data.Functor.Identity’
...plus six others
...plus 53 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 an equation for ‘abi_char’:
abi_char c = isAlphaNum c || c `elem` "-_."
|
66 | where abi_char c = isAlphaNum c || c `elem` "-_."
| ^^^^^^^^^^^^^^
Distribution/Types/ComponentId.hs:66:48: error:
• Could not deduce (IsString (t0 Char))
arising from the literal ‘"-_."’
from the context: CabalParsing m
bound by the type signature for:
parsec :: forall (m :: * -> *). CabalParsing m => m ComponentId
at Distribution/Types/ComponentId.hs:65:3-8
The type variable ‘t0’ is ambiguous
These potential instances exist:
instance IsString a => IsString (Identity a)
-- Defined in ‘Data.String’
instance (a ~ Char) => IsString [a] -- Defined in ‘Data.String’
...plus three instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the second argument of ‘elem’, namely ‘"-_."’
In the second argument of ‘(||)’, namely ‘c `elem` "-_."’
In the expression: isAlphaNum c || c `elem` "-_."
|
66 | where abi_char c = isAlphaNum c || c `elem` "-_."
| ^^^^^
Expected behavior
Code loads without errors.
System information
- OpenBSD 6.7
- cabal 3.3.0.0, ghc-8.10.1
Additional context
This can be resolved by explicit type annotations, but it's probably not the best way to deal with the errors:
diff --git a/Cabal/Distribution/Simple/GHC/EnvironmentParser.hs b/Cabal/Distribution/Simple/GHC/EnvironmentParser.hs
index f0ff8bc9c..27713132c 100644
--- a/Cabal/Distribution/Simple/GHC/EnvironmentParser.hs
+++ b/Cabal/Distribution/Simple/GHC/EnvironmentParser.hs
@@ -29,7 +29,7 @@ parseEnvironmentFileLine = GhcEnvFileComment <$> comment
where
comment = P.string "--" *> P.many (P.noneOf "\r\n")
unitId = P.try $ P.string "package-id" *> P.spaces *>
- (mkUnitId <$> P.many1 (P.satisfy $ \c -> isAlphaNum c || c `elem` "-_.+"))
+ (mkUnitId <$> P.many1 (P.satisfy $ \c -> isAlphaNum c || c `elem` ("-_.+" :: String)))
packageDb = (P.string "global-package-db" *> pure GlobalPackageDB)
<|> (P.string "user-package-db" *> pure UserPackageDB)
<|> (P.string "package-db" *> P.spaces *> (SpecificPackageDB <$> P.many1 (P.noneOf "\r\n") <* P.lookAhead P.endOfLine))
diff --git a/Cabal/Distribution/Simple/PreProcess.hs b/Cabal/Distribution/Simple/PreProcess.hs
index a34e38baa..aede8934a 100644
--- a/Cabal/Distribution/Simple/PreProcess.hs
+++ b/Cabal/Distribution/Simple/PreProcess.hs
@@ -542,7 +542,7 @@ ppC2hs bi lbi clbi =
--
--
-- DO NOT add Installed.cxxOptions unless this changes!
- , c `elem` "DIU" ] ]
+ , c `elem` ("DIU" :: String) ] ]
--TODO: install .chi files for packages, so we can --include
-- those dirs here, for the dependencies
@@ -568,7 +568,7 @@ getCppOptions bi lbi
= platformDefines lbi
++ cppOptions bi
++ ["-I" ++ dir | dir <- PD.includeDirs bi]
- ++ [opt | opt@('-':c:_) <- PD.ccOptions bi ++ PD.cxxOptions bi, c `elem` "DIU"]
+ ++ [opt | opt@('-':c:_) <- PD.ccOptions bi ++ PD.cxxOptions bi, c `elem` ("DIU"::String)]
platformDefines :: LocalBuildInfo -> [String]
platformDefines lbi =
diff --git a/Cabal/Distribution/Types/ComponentId.hs b/Cabal/Distribution/Types/ComponentId.hs
index e275ab6e5..c8be73912 100644
--- a/Cabal/Distribution/Types/ComponentId.hs
+++ b/Cabal/Distribution/Types/ComponentId.hs
@@ -63,7 +63,7 @@ instance Pretty ComponentId where
instance Parsec ComponentId where
parsec = mkComponentId `fmap` P.munch1 abi_char
- where abi_char c = isAlphaNum c || c `elem` "-_."
+ where abi_char c = isAlphaNum c || c `elem` ("-_." :: String)
instance NFData ComponentId where
rnf = rnf . unComponentId
Metadata
Metadata
Assignees
Labels
No labels