Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
- ignore: {name: "Use const"} # 36 hints
- ignore: {name: "Use fold"} # 1 hint
- ignore: {name: "Use fst"} # 2 hints
- ignore: {name: "Use lambda-case"} # 58 hints
- ignore: {name: "Use newtype instead of data"} # 31 hints
- ignore: {name: "Use null"} # 2 hints
- ignore: {name: "Use record patterns"} # 16 hints
Expand Down
11 changes: 6 additions & 5 deletions Cabal-syntax/src/Distribution/Fields/ConfVar.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}

module Distribution.Fields.ConfVar (parseConditionConfVar, parseConditionConfVarFromClause) where
Expand Down Expand Up @@ -35,7 +36,7 @@ import qualified Text.Parsec.Pos as P

parseConditionConfVarFromClause :: B8.ByteString -> Either P.ParseError (Condition ConfVar)
parseConditionConfVarFromClause x =
readFields x >>= \r -> case r of
readFields x >>= \case
(Section _ xs _ : _) -> P.runParser (parser <* P.eof) () "<condition>" xs
_ -> Left $ P.newErrorMessage (P.Message "No fields in clause") (P.initialPos "<condition>")

Expand Down Expand Up @@ -124,11 +125,11 @@ parser = condOr
]

-- Number token can have many dots in it: SecArgNum (Position 65 15) "7.6.1"
identBS = tokenPrim $ \t -> case t of
identBS = tokenPrim $ \case
SecArgName _ s -> Just s
_ -> Nothing

boolLiteral' = tokenPrim $ \t -> case t of
boolLiteral' = tokenPrim $ \case
SecArgName _ s
| s == "True" -> Just True
| s == "true" -> Just True
Expand All @@ -137,11 +138,11 @@ parser = condOr
_ -> Nothing

string :: B8.ByteString -> Parser ()
string s = tokenPrim $ \t -> case t of
string s = tokenPrim $ \case
SecArgName _ s' | s == s' -> Just ()
_ -> Nothing

oper o = tokenPrim $ \t -> case t of
oper o = tokenPrim $ \case
SecArgOther _ o' | o == o' -> Just ()
_ -> Nothing

Expand Down
19 changes: 10 additions & 9 deletions Cabal-syntax/src/Distribution/Fields/Parser.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}

Expand Down Expand Up @@ -124,15 +125,15 @@ tokIndent :: Parser Int
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 = 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
tokSym = getTokenWithPos $ \case L pos (TokSym x) -> Just (mkName pos x); _ -> Nothing
tokSym' = getTokenWithPos $ \case L pos (TokSym x) -> Just (SecArgName pos x); _ -> Nothing
tokStr = getTokenWithPos $ \case L pos (TokStr x) -> Just (SecArgStr pos x); _ -> Nothing
tokOther = getTokenWithPos $ \case L pos (TokOther x) -> Just (SecArgOther pos x); _ -> Nothing
tokIndent = getToken $ \case Indent x -> Just x; _ -> Nothing
tokColon = getToken $ \case Colon -> Just (); _ -> Nothing
tokOpenBrace = getTokenWithPos $ \case L pos OpenBrace -> Just pos; _ -> Nothing
tokCloseBrace = getToken $ \case CloseBrace -> Just (); _ -> Nothing
tokFieldLine = getTokenWithPos $ \case L pos (TokFieldLine s) -> Just (FieldLine pos s); _ -> Nothing

colon, openBrace, closeBrace :: Parser ()
sectionArg :: Parser (SectionArg Position)
Expand Down
3 changes: 2 additions & 1 deletion Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -560,7 +561,7 @@ versionRangeParser digitParser csv = expr
--
-- @since 2.2
majorUpperBound :: Version -> Version
majorUpperBound = alterVersion $ \numbers -> case numbers of
majorUpperBound = alterVersion $ \case
[] -> [0, 1] -- should not happen
[m1] -> [m1, 1] -- e.g. version '1'
(m1 : m2 : _) -> [m1, m2 + 1]
Expand Down
4 changes: 3 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE LambdaCase #-}

-- |
-- Module : Distribution.PackageDescription.Check.Target
-- Copyright : Lennart Kolmodin 2008, Francesco Ariis 2023
Expand Down Expand Up @@ -953,7 +955,7 @@ checkGHCOptions title t opts = do
)
(PackageDistInexcusable . DynamicUnneeded)
checkFlagsP
( \opt -> case opt of
( \case
"-j" -> True
('-' : 'j' : d : _) -> isDigit d
_ -> False
Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}

Expand Down Expand Up @@ -367,7 +368,7 @@ repl_setupHooks
verbosity = mkVerbosity verbHandles $ fromFlag (replVerbosity flags)

target <-
readTargetInfos verbosity pkg_descr lbi args >>= \r -> case r of
readTargetInfos verbosity pkg_descr lbi args >>= \case
-- This seems DEEPLY questionable.
[] -> case allTargetsInBuildOrder' pkg_descr lbi of
(target : _) -> return target
Expand Down
5 changes: 3 additions & 2 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -955,7 +956,7 @@ installLib verbosity lbi targetDir dynlibTargetDir bytecodeTargetDir _builtDir p
info verbosity ("Wanted install ways: " ++ show libWays)

-- copy .hi files over:
forM_ (wantedLibWays isIndef) $ \w -> case w of
forM_ (wantedLibWays isIndef) $ \case
StaticWay -> copyModuleFiles (Suffix "hi")
DynWay -> copyModuleFiles (Suffix "dyn_hi")
ProfWay -> copyModuleFiles (Suffix "p_hi")
Expand All @@ -970,7 +971,7 @@ installLib verbosity lbi targetDir dynlibTargetDir bytecodeTargetDir _builtDir p
-- without stripping; see doc/internal/bytecode-libraries.md.
whenBytecodeLib $ installOrdinaryNoStrip builtDir bytecodeTargetDir bytecodeLibName

forM_ libWays $ \w -> case w of
forM_ libWays $ \case
StaticWay -> do
sequence_
[ installOrdinary
Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -1256,7 +1257,7 @@ renderPureArgs version comp platform args =
, bool [] ["--gen-index"] . fromFlagOrDefault False . argGenIndex $ args
, maybe [] ((: []) . ("--base-url=" ++)) . flagToMaybe . argBaseUrl $ args
, bool [verbosityFlag] [] . getAny . argVerbose $ args
, map (\o -> case o of Hoogle -> "--hoogle"; Html -> "--html")
, map (\case Hoogle -> "--hoogle"; Html -> "--html")
. fromFlagOrDefault []
. argOutput
$ args
Expand Down
5 changes: 3 additions & 2 deletions Cabal/src/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ViewPatterns #-}
Expand Down Expand Up @@ -572,7 +573,7 @@ configureOptions showOrParseArgs =
[ optArgDef'
"n"
(show NoOptimisation, Flag . flagToOptimisationLevel)
( \f -> case f of
( \case
Flag NoOptimisation -> []
Flag NormalOptimisation -> [Nothing]
Flag MaximumOptimisation -> [Just "2"]
Expand All @@ -594,7 +595,7 @@ configureOptions showOrParseArgs =
[ optArg'
"n"
(Flag . flagToDebugInfoLevel)
( \f -> case f of
( \case
Flag NoDebugInfo -> []
Flag MinimalDebugInfo -> [Just "1"]
Flag NormalDebugInfo -> [Nothing]
Expand Down
7 changes: 4 additions & 3 deletions Cabal/src/Distribution/Simple/Setup/Copy.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ViewPatterns #-}
Expand Down Expand Up @@ -117,7 +118,7 @@ copyCommand =
, "COMPONENTS [FLAGS]"
]
, commandDefaultFlags = defaultCopyFlags
, commandOptions = \showOrParseArgs -> case showOrParseArgs of
, commandOptions = \case
ShowArgs ->
filter
( (`notElem` ["target-package-db"])
Expand Down Expand Up @@ -145,7 +146,7 @@ copyOptions showOrParseArgs =
( reqArg
"DIR"
(succeedReadE (Flag . CopyTo))
(\f -> case f of Flag (CopyTo p) -> [p]; _ -> [])
(\case Flag (CopyTo p) -> [p]; _ -> [])
)
, option
""
Expand All @@ -160,7 +161,7 @@ copyOptions showOrParseArgs =
( reqArg
"DATABASE"
(succeedReadE (Flag . CopyToDb))
(\f -> case f of Flag (CopyToDb p) -> [p]; _ -> [])
(\case Flag (CopyToDb p) -> [p]; _ -> [])
)
]

Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/Setup/Install.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ViewPatterns #-}
Expand Down Expand Up @@ -168,7 +169,7 @@ installOptions =
( reqArg
"DATABASE"
(succeedReadE (Flag . CopyToDb))
(\f -> case f of Flag (CopyToDb p) -> [p]; _ -> [])
(\case Flag (CopyToDb p) -> [p]; _ -> [])
)
]

Expand Down
30 changes: 14 additions & 16 deletions Cabal/src/Distribution/Utils/UnionFind.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NondecreasingIndentation #-}

-- | A simple mutable union-find data structure.
Expand Down Expand Up @@ -50,29 +51,26 @@ fresh desc = do
-- which points directly to the canonical representation.
repr :: Point s a -> ST s (Point s a)
repr point =
readPoint point >>= \r ->
case r of
Link point' -> do
point'' <- repr point'
when (point'' /= point') $ do
writePoint point =<< readPoint point'
return point''
Info _ _ -> return point
readPoint point >>= \case
Link point' -> do
point'' <- repr point'
when (point'' /= point') $ do
writePoint point =<< readPoint point'
return point''
Info _ _ -> return point

-- | Return the canonical element of an equivalence
-- class 'Point'.
find :: Point s a -> ST s a
find point =
-- Optimize length 0 and 1 case at expense of
-- general case
readPoint point >>= \r ->
case r of
Info _ d_ref -> readSTRef d_ref
Link point' ->
readPoint point' >>= \r' ->
case r' of
Info _ d_ref -> readSTRef d_ref
Link _ -> repr point >>= find
readPoint point >>= \case
Info _ d_ref -> readSTRef d_ref
Link point' ->
readPoint point' >>= \case
Info _ d_ref -> readSTRef d_ref
Link _ -> repr point >>= find

-- | Unify two equivalence classes, so that they share
-- a canonical element. Keeps the descriptor of point2.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}

-- | Fine-grained package dependencies
--
Expand Down Expand Up @@ -184,9 +185,10 @@ nonSetupDeps = select (/= ComponentSetup)
-- | Library dependencies proper only. (Includes dependencies
-- of internal libraries.)
libraryDeps :: Monoid a => ComponentDeps a -> a
libraryDeps = select (\c -> case c of ComponentSubLib _ -> True
ComponentLib -> True
_ -> False)
libraryDeps = select (\case
ComponentSubLib _ -> True
ComponentLib -> True
_ -> False)

-- | List components
components :: ComponentDeps a -> Set Component
Expand Down
Loading
Loading