Skip to content

Commit

Permalink
Merge branch 'master' into fix-7825
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini authored Oct 10, 2023
2 parents 9bf27f0 + 4067f93 commit 9691bd2
Show file tree
Hide file tree
Showing 100 changed files with 1,178 additions and 743 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-${{ github.sha }}
restore-keys: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-

- uses: actions/checkout@v3
- uses: actions/checkout@v4
# See https://github.com/haskell/cabal/pull/8739
- name: Sudo chmod to permit ghcup to update its cache
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/changelogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: cabal v2-update
# Cannot install it from tarball due to
# https://github.com/haskell/cabal/issues/7360
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: "fgaz/changelog-d"
path: "changelog-d"
Expand All @@ -59,7 +59,7 @@ jobs:
pushd changelog-d
cabal v2-install
popd
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run changelog-d
run: |
changelog-d changelog.d
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fourmolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: haskell-actions/run-fourmolu@v8
with:
pattern: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
hlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: haskell/actions/hlint-setup@v2
with:
version: "3.5"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quick-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: cabal v2-update
- name: Install alex
run: cabal v2-install alex --constraint='alex ==3.2.7.3'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Regenerate files
run: |
make -B lexer
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
ghcup install cabal --set latest
- name: Update Hackage index
run: cabal v2-update
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install doctest
run: make doctest-install
- name: Doctest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/users-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
python-version: ['3.10']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

# See the following link for a breakdown of the following step
# https://github.com/haskell/actions/issues/7#issuecomment-745697160
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
# cause it does not work with the git version included in it, see:
# https://github.com/actions/checkout/issues/170
# https://github.com/actions/checkout/issues/295
# - uses: actions/checkout@v3
# - uses: actions/checkout@v4
- name: Checkout
run: |
echo $GITHUB_REF $GITHUB_SHA
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
ghc: ${{ fromJSON (needs.validate.outputs.GHC_FOR_RELEASE) }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# See https://github.com/haskell/cabal/pull/8739
- name: Sudo chmod to permit ghcup to update its cache
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ brew_dir="${CI_PROJECT_DIR}/.brew"

if [ ! -e "${brew_dir}" ]; then
mkdir -p "${brew_dir}"
curl -L "https://github.com/Homebrew/brew/archive/refs/tags/${BREW_VERSION}.tar.gz" | tar xz --strip 1 -C "${brew_dir}"
curl --fail -L "https://github.com/Homebrew/brew/archive/refs/tags/${BREW_VERSION}.tar.gz" | tar xz --strip 1 -C "${brew_dir}"
fi

export PATH="${brew_dir}/bin:${brew_dir}/sbin:$PATH"
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ version: 2
sphinx:
configuration: doc/conf.py

build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python:
version: 3.8
install:
- requirements: doc/requirements.txt
21 changes: 17 additions & 4 deletions Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Test.QuickCheck.Instances.Cabal () where

import Control.Applicative (liftA2)
import Data.Bits (shiftR)
import Data.Char (isAlphaNum, isDigit)
import Data.List (intercalate)
import Data.Char (isAlphaNum, isDigit, toLower)
import Data.List (intercalate, (\\))
import Data.List.NonEmpty (NonEmpty (..))
import Distribution.Utils.Generic (lowercase)
import Test.QuickCheck
Expand Down Expand Up @@ -405,6 +405,10 @@ instance (Arbitrary a, Ord a) => Arbitrary (NubList a) where
-- InstallDirs
-------------------------------------------------------------------------------

-- these are wrong because they bottom out in String. We should really use
-- the modern FilePath at some point, so we get QC instances that don't include
-- invalid characters or path components

instance Arbitrary a => Arbitrary (InstallDirs a) where
arbitrary = InstallDirs
<$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary -- 4
Expand Down Expand Up @@ -506,11 +510,20 @@ arbitraryShortToken :: Gen String
arbitraryShortToken = arbitraryShortStringWithout "{}[]"

arbitraryShortPath :: Gen String
arbitraryShortPath = arbitraryShortStringWithout "{}[],"
arbitraryShortPath = arbitraryShortStringWithout "{}[],<>:|*?" `suchThat` (not . winDevice)
where
-- split path components on dots
-- no component can be empty or a device name
-- this blocks a little too much (both "foo..bar" and "foo.con" are legal)
-- but for QC being a little conservative isn't harmful
winDevice = any (any (`elem` ["","con", "aux", "prn", "com", "lpt", "nul"]) . splitBy ".") . splitBy "\\/" . map toLower
splitBy _ "" = []
splitBy seps str = let (part,rest) = break (`elem` seps) str
in part : if length rest == 1 then [""] else splitBy seps (drop 1 rest)

arbitraryShortStringWithout :: String -> Gen String
arbitraryShortStringWithout excludeChars =
shortListOf1 5 $ elements [c | c <- ['#' .. '~' ], c `notElem` excludeChars ]
shortListOf1 5 $ elements $ ['#' .. '~'] \\ excludeChars

-- |
intSqrt :: Int -> Int
Expand Down
4 changes: 2 additions & 2 deletions Cabal-syntax/Cabal-syntax.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ library
array >= 0.4.0.1 && < 0.6,
base >= 4.9 && < 5,
binary >= 0.7 && < 0.9,
bytestring >= 0.10.0.0 && < 0.12,
bytestring >= 0.10.0.0 && < 0.13,
containers >= 0.5.0.0 && < 0.7,
deepseq >= 1.3.0.1 && < 1.6,
directory >= 1.2 && < 1.4,
filepath >= 1.3.0.1 && < 1.5,
mtl >= 2.1 && < 2.4,
parsec >= 3.1.13.0 && < 3.2,
pretty >= 1.1.1 && < 1.2,
text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.1),
text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2),
time >= 1.4.0.1 && < 1.13,
-- transformers-0.4.0.0 doesn't have record syntax e.g. for Identity
-- See also https://github.com/ekmett/transformers-compat/issues/35
Expand Down
15 changes: 10 additions & 5 deletions Cabal-syntax/src/Distribution/Fields/LexerMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ data LexWarningType
LexWarningTab
| -- | indentation decreases
LexInconsistentIndentation
| -- | Brace syntax used
LexBraces
deriving (Eq, Ord, Show)

data LexWarning
Expand All @@ -79,19 +81,22 @@ data LexWarning

toPWarnings :: [LexWarning] -> [PWarning]
toPWarnings =
map (uncurry toWarning)
mapMaybe (uncurry toWarning)
. Map.toList
. Map.fromListWith (flip (<>)) -- fromListWith gives existing element first.
. map (\(LexWarning t p) -> (t, pure p))
where
toWarning LexWarningBOM poss =
PWarning PWTLexBOM (NE.head poss) "Byte-order mark found at the beginning of the file"
Just $ PWarning PWTLexBOM (NE.head poss) "Byte-order mark found at the beginning of the file"
toWarning LexWarningNBSP poss =
PWarning PWTLexNBSP (NE.head poss) $ "Non breaking spaces at " ++ intercalate ", " (NE.toList $ fmap showPos poss)
Just $ PWarning PWTLexNBSP (NE.head poss) $ "Non breaking spaces at " ++ intercalate ", " (NE.toList $ fmap showPos poss)
toWarning LexWarningTab poss =
PWarning PWTLexTab (NE.head poss) $ "Tabs used as indentation at " ++ intercalate ", " (NE.toList $ fmap showPos poss)
Just $ PWarning PWTLexTab (NE.head poss) $ "Tabs used as indentation at " ++ intercalate ", " (NE.toList $ fmap showPos poss)
toWarning LexInconsistentIndentation poss =
PWarning PWTInconsistentIndentation (NE.head poss) $ "Inconsistent indentation. Indentation jumps at lines " ++ intercalate ", " (NE.toList $ fmap (show . positionRow) poss)
Just $ PWarning PWTInconsistentIndentation (NE.head poss) $ "Inconsistent indentation. Indentation jumps at lines " ++ intercalate ", " (NE.toList $ fmap (show . positionRow) poss)
-- LexBraces warning about using { } delimeters is not reported as parser warning.
toWarning LexBraces _ =
Nothing

{- FOURMOLU_DISABLE -}
data LexState = LexState
Expand Down
15 changes: 11 additions & 4 deletions Cabal-syntax/src/Distribution/Fields/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import qualified Data.Text.Encoding.Error as T
#endif

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Data.Either (isLeft)

-- | The 'LexState'' (with a prime) is an instance of parsec's 'Stream'
Expand All @@ -86,6 +85,11 @@ getLexerWarnings = do
LexState' (LexState{warnings = ws}) _ <- getInput
return ws

addLexerWarning :: LexWarning -> Parser ()
addLexerWarning w = do
LexState' ls@LexState{warnings = ws} _ <- getInput
setInput $! mkLexState' ls{warnings = w : ws}

-- | Set Alex code i.e. the mode "state" lexer is in.
setLexerMode :: Int -> Parser ()
setLexerMode code = do
Expand Down Expand Up @@ -118,15 +122,16 @@ describeToken t = case t of
tokSym :: Parser (Name Position)
tokSym', tokStr, tokOther :: Parser (SectionArg Position)
tokIndent :: Parser Int
tokColon, tokOpenBrace, tokCloseBrace :: Parser ()
tokColon, tokCloseBrace :: Parser ()
tokOpenBrace :: Parser Position
tokFieldLine :: Parser (FieldLine Position)
tokSym = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (mkName pos x); _ -> Nothing
tokSym' = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (SecArgName pos x); _ -> Nothing
tokStr = getTokenWithPos $ \t -> case t of L pos (TokStr x) -> Just (SecArgStr pos x); _ -> Nothing
tokOther = getTokenWithPos $ \t -> case t of L pos (TokOther x) -> Just (SecArgOther pos x); _ -> Nothing
tokIndent = getToken $ \t -> case t of Indent x -> Just x; _ -> Nothing
tokColon = getToken $ \t -> case t of Colon -> Just (); _ -> Nothing
tokOpenBrace = getToken $ \t -> case t of OpenBrace -> Just (); _ -> Nothing
tokOpenBrace = getTokenWithPos $ \t -> case t of L pos OpenBrace -> Just pos; _ -> Nothing
tokCloseBrace = getToken $ \t -> case t of CloseBrace -> Just (); _ -> Nothing
tokFieldLine = getTokenWithPos $ \t -> case t of L pos (TokFieldLine s) -> Just (FieldLine pos s); _ -> Nothing

Expand All @@ -138,7 +143,9 @@ fieldSecName :: Parser (Name Position)
fieldSecName = tokSym <?> "field or section name"

colon = tokColon <?> "\":\""
openBrace = tokOpenBrace <?> "\"{\""
openBrace = do
pos <- tokOpenBrace <?> "\"{\""
addLexerWarning (LexWarning LexBraces pos)
closeBrace = tokCloseBrace <?> "\"}\""

fieldContent :: Parser (FieldLine Position)
Expand Down
5 changes: 1 addition & 4 deletions Cabal-syntax/src/Distribution/InstalledPackageInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ import qualified Text.PrettyPrint as Disp
import Distribution.Types.InstalledPackageInfo
import Distribution.Types.InstalledPackageInfo.FieldGrammar

-- $setup
-- >>> :set -XOverloadedStrings

installedComponentId :: InstalledPackageInfo -> ComponentId
installedComponentId ipi =
case unComponentId (installedComponentId_ ipi) of
Expand Down Expand Up @@ -130,7 +127,7 @@ showFullInstalledPackageInfo = P.showFields (const NoComment) . prettyFieldGramm

-- |
--
-- >>> let ipi = emptyInstalledPackageInfo { maintainer = "Tester" }
-- >>> let ipi = emptyInstalledPackageInfo { maintainer = fromString "Tester" }
-- >>> fmap ($ ipi) $ showInstalledPackageInfoField "maintainer"
-- Just "maintainer: Tester"
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
Expand Down
4 changes: 3 additions & 1 deletion Cabal-syntax/src/Distribution/System.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ buildOS = classifyOS Permissive System.Info.os

-- | These are the known Arches: I386, X86_64, PPC, PPC64, Sparc,
-- Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa, Rs6000,
-- M68k, Vax, RISCV64, JavaScript and Wasm32.
-- M68k, Vax, RISCV64, LoongArch64, JavaScript and Wasm32.
--
-- The following aliases can also be used:
-- * PPC alias: powerpc
Expand Down Expand Up @@ -211,6 +211,7 @@ data Arch
| M68k
| Vax
| RISCV64
| LoongArch64
| JavaScript
| Wasm32
| OtherArch String
Expand Down Expand Up @@ -240,6 +241,7 @@ knownArches =
, M68k
, Vax
, RISCV64
, LoongArch64
, JavaScript
, Wasm32
]
Expand Down
8 changes: 4 additions & 4 deletions Cabal-syntax/src/Distribution/Types/Dependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ instance NFData Dependency where rnf = genericRnf

-- |
--
-- >>> prettyShow $ Dependency "pkg" anyVersion mainLibSet
-- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion mainLibSet
-- "pkg"
--
-- >>> prettyShow $ Dependency "pkg" anyVersion $ NES.insert (LSubLibName "sublib") mainLibSet
-- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib") mainLibSet
-- "pkg:{pkg, sublib}"
--
-- >>> prettyShow $ Dependency "pkg" anyVersion $ NES.singleton (LSubLibName "sublib")
-- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib")
-- "pkg:sublib"
--
-- >>> prettyShow $ Dependency "pkg" anyVersion $ NES.insert (LSubLibName "sublib-b") $ NES.singleton (LSubLibName "sublib-a")
-- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib-b") $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib-a")
-- "pkg:{sublib-a, sublib-b}"
instance Pretty Dependency where
pretty (Dependency name ver sublibs) = withSubLibs (pretty name) <+> pver
Expand Down
4 changes: 2 additions & 2 deletions Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ tests = testGroup "Distribution.Utils.Structured"
-- The difference is in encoding of newtypes
#if MIN_VERSION_base(4,7,0)
, testCase "GenericPackageDescription" $
md5Check (Proxy :: Proxy GenericPackageDescription) 0xedd391339de1201511636bbb563fa5db
md5Check (Proxy :: Proxy GenericPackageDescription) 0x6ad1e12c6f88291e9b8c131d239eda70
, testCase "LocalBuildInfo" $
md5Check (Proxy :: Proxy LocalBuildInfo) 0x40253e3699453643336bdc7911717af0
md5Check (Proxy :: Proxy LocalBuildInfo) 0xbc7ac84a9bc43345c812af222c3e5ba0
#endif
]

Expand Down
4 changes: 2 additions & 2 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ library
Cabal-syntax ^>= 3.11,
array >= 0.4.0.1 && < 0.6,
base >= 4.9 && < 5,
bytestring >= 0.10.0.0 && < 0.12,
bytestring >= 0.10.0.0 && < 0.13,
containers >= 0.5.0.0 && < 0.7,
deepseq >= 1.3.0.1 && < 1.6,
directory >= 1.2 && < 1.4,
Expand Down Expand Up @@ -305,7 +305,7 @@ library
-- See also https://github.com/ekmett/transformers-compat/issues/35
transformers (>= 0.3 && < 0.4) || (>=0.4.1.0 && <0.7),
mtl >= 2.1 && < 2.4,
text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.1),
text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2),
parsec >= 3.1.13.0 && < 3.2

other-modules:
Expand Down
9 changes: 4 additions & 5 deletions Cabal/src/Distribution/Simple/Errors.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
-----------------------------------------------------------------------------

-- Module : Distribution.Simple.Errors
-- Copyright :
-- License :
--
-- Maintainer :
-- Portability :
-- Copyright : Suganya Arun
-- License : BSD3
-- Maintainer : [email protected]
-- Portability : portable
--
-- A collection of Exception Types in the Cabal library package

Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir =
, ghcOptFfiIncludes = toNubListR $ includes bi
, ghcOptObjDir = toFlag odir
, ghcOptHiDir = toFlag odir
, ghcOptHieDir = bool NoFlag (toFlag $ odir </> extraCompilationArtifacts) $ flagHie implInfo
, ghcOptHieDir = bool NoFlag (toFlag $ odir </> extraCompilationArtifacts </> "hie") $ flagHie implInfo
, ghcOptStubDir = toFlag odir
, ghcOptOutputDir = toFlag odir
, ghcOptOptimisation = toGhcOptimisation (withOptimization lbi)
Expand Down
1 change: 1 addition & 0 deletions Cabal/src/Distribution/Simple/PreProcess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ platformDefines lbi =
M68k -> ["m68k"]
Vax -> ["vax"]
RISCV64 -> ["riscv64"]
LoongArch64 -> ["loongarch64"]
JavaScript -> ["javascript"]
Wasm32 -> ["wasm32"]
OtherArch _ -> []
Expand Down
Loading

0 comments on commit 9691bd2

Please sign in to comment.