8000 Cosmetics: activate warning operator-whitespace by andreasabel · Pull Request #6929 · agda/agda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Cosmetics: activate warning operator-whitespace #6929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023
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
2 changes: 1 addition & 1 deletion Agda.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ common language

if impl(ghc >= 9.2)
ghc-options:
-- -Werror=operator-whitespace
-Werror=operator-whitespace
-Werror=redundant-bang-patterns

if impl(ghc >= 9.4)
Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Auto/Auto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ auto ii rng argstr = liftTCM $ locallyTC eMakeCase (const True) $ do

hits <- if "-a" `elem` hints then do
st <- liftTCM $ join $ pureTCM $ \st _ -> return st
let defs = st^.stSignature.sigDefinitions
idefs = st^.stImports.sigDefinitions
let defs = st ^. stSignature . sigDefinitions
idefs = st ^. stImports . sigDefinitions
alldefs = HMap.keys defs ++ HMap.keys idefs
catMaybes <$> mapM (\n ->
case thisdefinfo of
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Auto/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ instance Weakening (ICArgList o) where
CALConcat a as -> CALConcat (weak' n a) (weak' n as)

instance Weakening (Elr o) where
weak' n = rename (n+)
weak' n = rename (n +)

-- | Substituting for a variable.
doclos :: [CAction o] -> Nat -> Either Nat (ICExp o)
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Auto/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tcExp isdep ctx typ@(TrBr typtrs ityp@(Clos _ itypexp)) trm =
Var v ->
case ctx !!! v of
Nothing -> return Nothing
Just (_, a) -> return $ Just (weak (v+1) a, id)
Just (_, a) -> return $ Just (weak (v + 1) a, id)
Const c -> do
cdef <- readIORef c
return $ Just (closify (cdtype cdef), mpret . And (Just [Term args]) (noiotastep_term c args))
Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Compiler/JS/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ definition' kit q d t ls =
let (body, given) = lamView funBody
where
lamView :: T.TTerm -> (T.TTerm, Int)
lamView (T.TLam t) = (+1) <$> lamView t
lamView (T.TLam t) = (+ 1) <$> lamView t
lamView t = (t, 0)

-- number of eta expanded args
Expand Down Expand Up @@ -609,7 +609,7 @@ compileTerm kit t = go t
unit = return Null

mkArray xs
| 2 * length (filter ((==Null) . snd) xs) <= length xs = Array xs
| 2 * length (filter ((== Null) . snd) xs) <= length xs = Array xs
| otherwise = Object $ Map.fromListWith __IMPOSSIBLE__
[ (MemberIndex i c, x) | (i, (c, x)) <- zip [0..] xs, x /= Null ]

Expand Down
8 changes: 4 additions & 4 deletions src/full/Agda/Compiler/JS/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ render minify = intercalate "\n" . joinLines . map (uncurry mkIndent) . go 0
go i (Doc s) = [(i, s)]
go i (Beside d d') = joinBy (\(i, s) (_, s') -> [(i, s ++ s')]) (go i d) (go i d')
go i (Above d d') = joinBy overlay (go i d) (go i d')
go i (Indent j d) = go (i+j) d
go i (Indent j d) = go (i + j) d
go i (Enclose open close d) = go i $ Group $ Above open $ Above d close
go i (Group d)
| size ss < 40 = compact ss
Expand Down Expand Up @@ -143,7 +143,7 @@ group = Group

indentBy :: Int -> Doc -> Doc
indentBy i Empty = Empty
indentBy i (Indent j d) = Indent (i+j) d
indentBy i (Indent j d) = Indent (i + j) d
indentBy i d = Indent i d

enclose :: Doc -> Doc -> Doc -> Doc
Expand Down Expand Up @@ -261,8 +261,8 @@ instance Pretty Exp where
pretty n (Integer x) = "agdaRTS.primIntegerFromString(\"" <> text (show x) <> "\")"
pretty n (Double x) = text $ show x
pretty (n, min, ms) (Lambda x e) =
mparens (x /= 1) (punctuate "," (pretties (n+x, min, ms) (map LocalId [x-1, x-2 .. 0])))
<+> "=>" <+> block (n+x, min, ms) e
mparens (x /= 1) (punctuate "," (pretties (n + x, min, ms) (map LocalId [x-1, x-2 .. 0])))
<+> "=>" <+> block (n + x, min, ms) e
pretty n (Object o) = braces $ punctuate "," $ pretties n o
pretty n (Array es) = brackets $ punctuate "," [pretty n c <> pretty n e | (c, e) <- es]
pretty n (Apply f es) = pretty n f <> parens (punctuate "," $ pretties n es)
Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Compiler/ToTreeless.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type CCContext = [Int]
type CC = ReaderT CCEnv TCM

shift :: Int -> CCContext -> CCContext
shift n = map (+n)
shift n = map (+ n)

-- | Term variables are de Bruijn indices.
lookupIndex :: Int -- ^ Case tree de bruijn index.
Expand Down Expand Up @@ -468,7 +468,7 @@ replaceVar x n cont = do
(ys, _:zs) = splitAt i cxt
-- compute the de-bruijn indexes of the newly inserted variables
ixs = [0..(n - 1)]
local (\e -> e { ccCxt = upd (ccCxt e) , ccCatchAll = (+n) <$> ccCatchAll e }) $
local (\e -> e { ccCxt = upd (ccCxt e) , ccCatchAll = (+ n) <$> ccCatchAll e }) $
cont


Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Compiler/Treeless/Simplify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ simplify FunctionKit{..} = simpl
k == j = tOp PLt v u
| Just (PAdd, k, v) <- constArithView v,
TApp (TPrim P64ToI) [u] <- u,
k >= 2^64, Just trueCon <- true = TCon trueCon
k >= 2 ^ 64, Just trueCon <- true = TCon trueCon
| Just k <- intView u
, Just j <- intView v
, Just trueCon <- true
Expand Down Expand Up @@ -458,7 +458,7 @@ simplify FunctionKit{..} = simpl
literal _ _ = False

-- k + fromWord x ≤ y if k + 2^64 - 1 ≤ y
wordUpperBound (k, [Pos (TApp (TPrim P64ToI) _)]) y = go (k + 2^64 - 1, []) y
wordUpperBound (k, [Pos (TApp (TPrim P64ToI) _)]) y = go (k + 2 ^ 64 - 1, []) y
wordUpperBound _ _ = False

-- x ≤ k + fromWord y if x ≤ k
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Interaction/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ parseToReadsPrec p i s = case runIdentity . flip runStateT s . runExceptT $ pare
-- | Demand an exact string.

exact :: String -> Parse ()
exact s = readsToParse (show s) $ fmap ((),) . List.stripPrefix s . dropWhile (==' ')
exact s = readsToParse (show s) $ fmap ((),) . List.stripPrefix s . dropWhile (== ' ')

readParse :: Read a => Parse a
readParse = readsToParse "read failed" $ listToMaybe . reads
Expand Down
6 changes: 3 additions & 3 deletions src/full/Agda/Interaction/Highlighting/Vim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ matches cons icons defs idefs flds iflds =
toVim :: NamesInScope -> String
toVim ns = unlines $ matches mcons micons mdefs midefs mflds miflds
where
cons = [ x | (x, con:|_) <- Map.toList ns, isJust $ isConName $ anameKind con ]
defs = [ x | (x, def:|_) <- Map.toList ns, isDefName (anameKind def) ]
flds = [ x | (x, fld:|_) <- Map.toList ns, anameKind fld == FldName ]
cons = [ x | (x, con :| _) <- Map.toList ns, isJust $ isConName $ anameKind con ]
defs = [ x | (x, def :| _) <- Map.toList ns, isDefName (anameKind def) ]
flds = [ x | (x, fld :| _) <- Map.toList ns, anameKind fld == FldName ]

mcons = map prettyShow cons
mdefs = map prettyShow defs
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Interaction/Library/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ parseLine l s@(c:_)
| isSpace c = pure [Content l $ ltrim s]
-- Non-indented lines are 'Header'.
| otherwise =
case break (==':') s of
case break (== ':') s of
-- Headers are single words followed by a colon.
-- Anything after the colon that is not whitespace is 'Content'.
(h, ':' : r) ->
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Interaction/Options/Lenses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ instance LensPragmaOptions CommandLineOptions where
lensPragmaOptions f st = f (optPragmaOptions st) <&> \ opts -> st { optPragmaOptions = opts }

instance LensPragmaOptions TCState where
getPragmaOptions = (^.stPragmaOptions)
getPragmaOptions = (^. stPragmaOptions)
setPragmaOptions = set stPragmaOptions
lensPragmaOptions = stPragmaOptions

Expand Down
8 changes: 4 additions & 4 deletions src/full/Agda/Syntax/Abstract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,10 @@ instance LensHiding LamBinding where
mapHiding f (DomainFull tb) = DomainFull $ mapHiding f tb

instance LensHiding TypedBinding where
getHiding (TBind _ _ (x :|_) _) = getHiding x -- Slightly dubious
getHiding TLet{} = mempty
mapHiding f (TBind r t xs e) = TBind r t ((fmap . mapHiding) f xs) e
mapHiding f b@TLet{} = b
getHiding (TBind _ _ (x :| _) _) = getHiding x -- Slightly dubious
getHiding TLet{} = mempty
mapHiding f (TBind r t xs e) = TBind r t ((fmap . mapHiding) f xs) e
mapHiding f b@TLet{} = b

instance HasRange a => HasRange (Binder' a) where
getRange (Binder p n) = fuseRange p n
Expand Down
6 changes: 3 additions & 3 deletions src/full/Agda/Syntax/Concrete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,13 @@ instance LensHiding LamBinding where

instance LensHiding TypedBinding where
getHiding (TBind _ (x :| _) _) = getHiding x -- Slightly dubious
getHiding TLet{} = mempty
getHiding TLet{} = mempty
mapHiding f (TBind r xs e) = TBind r (fmap (mapHiding f) xs) e
mapHiding f b@TLet{} = b

instance LensRelevance TypedBinding where
getRelevance (TBind _ (x :|_) _) = getRelevance x -- Slightly dubious
getRelevance TLet{} = unitRelevance
getRelevance (TBind _ (x :| _) _) = getRelevance x -- Slightly dubious
getRelevance TLet{} = unitRelevance
mapRelevance f (TBind r xs e) = TBind r (fmap (mapRelevance f) xs) e
mapRelevance f b@TLet{} = b

Expand Down
12 changes: 6 additions & 6 deletions src/full/Agda/Syntax/Concrete/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ niceDeclarations fixs ds = do
addType n c mc = do
(m, checks, i) <- get
when (isJust $ Map.lookup n m) $ lift $ declarationException $ DuplicateDefinition n
put (Map.insert n (c i) m, mc <> checks, i+1)
put (Map.insert n (c i) m, mc <> checks, i + 1)

addFunType d@(FunSig _ _ _ _ _ _ tc cc n _) = do
let checks = MutualChecks [tc] [cc] []
Expand All @@ -905,7 +905,7 @@ niceDeclarations fixs ds = do
lift $ removeLoneSig n
-- add the constructors to the existing ones (if any)
let (cs', i') = case cs of
Nothing -> ((i , ds :| [] ), i+1)
Nothing -> ((i , ds :| [] ), i + 1)
Just (i1, ds1) -> ((i1, ds <| ds1), i)
put (Map.insert n (InterleavedData i0 sig (Just cs')) m, checks, i')
_ -> lift $ declarationWarning $ MissingDeclarations $ case mr of
Expand Down Expand Up @@ -938,7 +938,7 @@ niceDeclarations fixs ds = do
case Map.lookup n m of
Just (InterleavedFun i0 sig cs0) -> do
let (cs', i') = case cs0 of
Nothing -> ((i, (ds, cs) :| [] ), i+1)
Nothing -> ((i, (ds, cs) :| [] ), i + 1)
Just (i1, cs1) -> ((i1, (ds, cs) <| cs1), i)
put (Map.insert n (InterleavedFun i0 sig (Just cs')) m, check <> checks, i')
_ -> __IMPOSSIBLE__ -- A FunDef always come after an existing FunSig!
Expand All @@ -959,7 +959,7 @@ niceDeclarations fixs ds = do
-- no candidate: keep the isolated fun clause, we'll complain about it later
[] -> do
let check = MutualChecks [tc] [cc] []
put (m, check <> checks, i+1)
put (m, check <> checks, i + 1)
((i,nd) :) <$> groupByBlocks r ds
-- exactly one candidate: attach the funclause to the definition
[(n, fits0, rest)] -> do
Expand All @@ -969,7 +969,7 @@ niceDeclarations fixs ds = do
case Map.lookup n m of
Just (InterleavedFun i0 sig cs0) -> do
let (cs', i') = case cs0 of
Nothing -> ((i, (fits,cs) :| [] ), i+1)
Nothing -> ((i, (fits,cs) :| [] ), i + 1)
Just (i1, cs1) -> ((i1, (fits,cs) <| cs1), i)
let checks' = Fold.fold checkss
put (Map.insert n (InterleavedFun i0 sig (Just cs')) m, checks' <> checks, i')
Expand Down Expand Up @@ -1001,7 +1001,7 @@ niceDeclarations fixs ds = do
-- of each for record definitions and leaving them in place should be enough!
_ -> oneOff $ do
(m, c, i) <- get -- TODO: grab checks from c?
put (m, c, i+1)
put (m, c, i + 1)
pure [(i,d)]

-- Extract the name of the return type (if any) of a potential constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Syntax/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ readFilePM file =

wrapIOM :: (MonadError e m, MonadIO m) => (IOError -> e) -> IO a -> m a
wrapIOM f m = do
a <- liftIO$ (Right <$> m) `catch` (\err -> return$ Left (err :: IOError))
a <- liftIO $ (Right <$> m) `catch` (\ err -> return $ Left (err :: IOError))
case a of
Right x -> return x
Left err -> throwError (f err)
Expand Down
6 changes: 3 additions & 3 deletions src/full/Agda/Syntax/Scope/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ addVarToBind x y = modifyScope_ $ updateVarsToBind $ AssocList.insert x y
bindVarsToBind :: ScopeM ()
bindVarsToBind = do
vars <- getVarsToBind
modifyLocalVars (vars++)
modifyLocalVars (vars ++)
printLocals 10 "bound variables:"
modifyScope_ $ setVarsToBind []

Expand Down Expand Up @@ -311,7 +311,7 @@ freshConcreteName r i s = do
let cname = C.Name r C.NotInScope $ singleton $ Id $ stringToRawName $ s ++ show i
resolveName (C.QName cname) >>= \case
UnknownName -> return cname
_ -> freshConcreteName r (i+1) s
_ -> freshConcreteName r (i + 1) s

---------------------------------------------------------------------------
-- * Resolving names
Expand Down Expand Up @@ -1029,7 +1029,7 @@ openModule kind mam cm dir = do
where ks = fmap anameKind qs
-- We report the first clashing exported identifier.
unlessNull (filter defClash defClashes) $
\ ((x, q:|_) : _) -> typeError $ ClashingDefinition (C.QName x) (anameName q) Nothing
\ ((x, q :| _) : _) -> typeError $ ClashingDefinition (C.QName x) (anameName q) Nothing

unlessNull modClashes $ \ ((_, ms) : _) -> do
caseMaybe (List1.last2 ms) __IMPOSSIBLE__ $ \ (m0, m1) -> do
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Syntax/Translation/AbstractToConcrete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ instance ToConcrete a => ToConcrete [a] where

toConcrete = mapM toConcrete
bindToConcrete [] ret = ret []
bindToConcrete (a:as) ret = bindToConcrete (a:|as) $ \ (c:|cs) -> ret (c:cs)
bindToConcrete (a:as) ret = bindToConcrete (a :| as) $ \ (c :| cs) -> ret (c:cs)

instance ToConcrete a => ToConcrete (List1 a) where
type ConOfAbs (List1 a) = List1 (ConOfAbs a)
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Syntax/Translation/ConcreteToAbstract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2805,7 +2805,7 @@ instance ToAbstract RightHandSide where
ns <- toAbstract ns
lvars1 <- getLocalVars
let lv' = dropEnd (length lvars0) lvars1 ++ lv
let cs' = for (c:|cs) $ \ c -> setLocalVars lv' $> c
let cs' = for (c :| cs) $ \ c -> setLocalVars lv' $> c
let nes = zipWith Named ns es
return $ WithRHS' nes cs'
-- TODO: some of these might be possible
Expand Down
4 changes: 2 additions & 2 deletions src/full/Agda/Termination/SparseMatrix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Diagonal m e | m -> e where
instance (Integral i, HasZero b) => Diagonal (Matrix i b) b where
diagonal (Matrix (Size r c) m) =
blowUpSparseVec zeroElement (min r c) $
mapMaybe (\ ((MIx i j), b) -> if i==j then Just (i,b) else Nothing) m
mapMaybe (\ (MIx i j, b) -> if i == j then Just (i, b) else Nothing) m

-- | Transposable things.

Expand Down Expand Up @@ -400,7 +400,7 @@ instance (Ord i, PartialOrd a) => PartialOrd (Matrix i a) where
both = comparable
-- The zero element of the result sparse matrix is the
-- neutral element of the monoid.
trivial = (==mempty)
trivial = (== mempty)

------------------------------------------------------------------------
-- Modifying matrices
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/Termination/TermCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ compareProj d d'
case def of
Record{ recFields = fs } -> do
fs <- return $ map unDom fs
case (List.find (d==) fs, List.find (d'==) fs) of
case (List.find (d ==) fs, List.find (d' ==) fs) of
(Just i, Just i')
-- earlier field is smaller
| i < i' -> return Order.lt
Expand Down
6 changes: 3 additions & 3 deletions src/full/Agda/TypeChecking/Conversion.hs
CAB0
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ leqLevel a b = catchConstraint (LevelCmp CmpLeq a b) $ do
| all neutralOrClosed bs , levelLowerBound a > levelLowerBound b -> notok

-- ⊔ as ≤ single
(as@(_:|_:_), b :| []) ->
(as@(_ :| _ : _), b :| []) ->
forM_ as $ \ a' -> leqLevel (unSingleLevel $ ignoreBlocking <$> a')
(unSingleLevel $ ignoreBlocking <$> b)

Expand Down Expand Up @@ -1586,9 +1586,9 @@ equalLevel a b = do
(_ , SingleClosed n :| []) | n < levelLowerBound a -> notok

-- 0 == a ⊔ b
(SingleClosed 0 :| [] , bs@(_:|_:_)) ->
(SingleClosed 0 :| [] , bs@(_ :| _ : _)) ->
forM_ bs $ \ b' -> equalLevel (ClosedLevel 0) (unSingleLevel $ ignoreBlocking <$> b')
(as@(_:|_:_) , SingleClosed 0 :| []) ->
(as@(_ :| _ : _) , SingleClosed 0 :| []) ->
forM_ as $ \ a' -> equalLevel (unSingleLevel $ ignoreBlocking <$> a') (ClosedLevel 0)

-- meta == any
Expand Down
6 changes: 3 additions & 3 deletions src/full/Agda/TypeChecking/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,13 @@ cover f cs sc@(SClause tel ps _ _ target) = updateRelevance $ do
addEtaSplits :: Int -> [NamedArg SplitPattern] -> SplitTree -> SplitTree
addEtaSplits k [] t = t
addEtaSplits k (p:ps) t = case namedArg p of
VarP _ _ -> addEtaSplits (k+1) ps t
DotP _ _ -> addEtaSplits (k+1) ps t
VarP _ _ -> addEtaSplits (k + 1) ps t
DotP _ _ -> addEtaSplits (k + 1) ps t
ConP c cpi qs -> SplitAt (p $> k) LazySplit [(SplitCon (conName c) , addEtaSplits k (qs ++ ps) t)]
LitP{} -> __IMPOSSIBLE__
ProjP{} -> __IMPOSSIBLE__
DefP{} -> __IMPOSSIBLE__ -- Andrea: maybe?
IApplyP{} -> addEtaSplits (k+1) ps t
IApplyP{} -> addEtaSplits (k + 1) ps t

etaRecordSplits :: Int -> [NamedArg SplitPattern] -> (SplitTag,SplitClause)
-> SplitTree -> (SplitTag,SplitTree)
Expand Down
Loading
0