Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
-
fed942ac
by Andreas Klebinger at 2026-08-17T12:11:57-04:00
-
574c875f
by Andreas Klebinger at 2026-08-17T12:12:39-04:00
-
d8f1a2a3
by Alan Zimmerman at 2026-08-17T12:13:18-04:00
-
c556ed58
by Andreas Klebinger at 2026-08-17T17:50:10-04:00
-
bb344b5f
by Simon Jakobi at 2026-08-17T17:50:11-04:00
29 changed files:
- .gitlab-ci.yml
- compiler/GHC/Builtin/WiredIn/Types.hs
- compiler/GHC/CmmToAsm/Format.hs
- compiler/GHC/Core/Class.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Data/BooleanFormula.hs
- compiler/GHC/Data/Word64Map/Internal.hs
- compiler/GHC/Data/Word64Map/Lazy.hs
- compiler/GHC/Data/Word64Map/Strict.hs
- compiler/GHC/Data/Word64Map/Strict/Internal.hs
- compiler/GHC/Driver/GenerateCgIPEStub.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy/StaticPtrTable.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Parser.y
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/TyCl/Class.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/Unique/DFM.hs
- compiler/GHC/Types/Var.hs
- compiler/Language/Haskell/Syntax/BooleanFormula.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- testsuite/tests/process/process009.hs
- testsuite/tests/process/process009.stdout
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
Changes:
| ... | ... | @@ -552,6 +552,8 @@ stack-hadrian-build: |
| 552 | 552 | - . .gitlab/ci.sh setup
|
| 553 | 553 | - . .gitlab/ci.sh configure
|
| 554 | 554 | - hadrian/build-stack --version
|
| 555 | + rules:
|
|
| 556 | + - *full-ci
|
|
| 555 | 557 | |
| 556 | 558 | ####################################
|
| 557 | 559 | # Testing reinstallable ghc codepath
|
| ... | ... | @@ -783,7 +783,7 @@ typeSymbolKind = mkTyConTy typeSymbolKindCon |
| 783 | 783 | Note [How tuples work]
|
| 784 | 784 | ~~~~~~~~~~~~~~~~~~~~~~
|
| 785 | 785 | * There are three families of tuple TyCons and corresponding
|
| 786 | - DataCons, expressed by the type BasicTypes.TupleSort:
|
|
| 786 | + DataCons, expressed by the type GHC.Types.Basic.TupleSort:
|
|
| 787 | 787 | data TupleSort = BoxedTuple | UnboxedTuple | ConstraintTuple
|
| 788 | 788 | |
| 789 | 789 | * All three families are AlgTyCons, whose AlgTyConRhs is TupleTyCon
|
| ... | ... | @@ -818,7 +818,7 @@ Note [How tuples work] |
| 818 | 818 | stores them in the context field of types like HsQualTy.
|
| 819 | 819 | |
| 820 | 820 | * In quite a lot of places things are restricted just to
|
| 821 | - BoxedTuple/UnboxedTuple, and then we used BasicTypes.Boxity to distinguish
|
|
| 821 | + BoxedTuple/UnboxedTuple, and then we used GHC.Types.Basic.Boxity to distinguish
|
|
| 822 | 822 | E.g. tupleTyCon has a Boxity argument
|
| 823 | 823 | |
| 824 | 824 | * When looking up an OccName in the original-name cache
|
| ... | ... | @@ -52,20 +52,20 @@ import GHC.Utils.Panic |
| 52 | 52 | GHC has severals types that represent various aspects of data format.
|
| 53 | 53 | These include:
|
| 54 | 54 | |
| 55 | - * 'CmmType.CmmType': The data classification used throughout the C--
|
|
| 55 | + * 'GHC.Cmm.Type.CmmType': The data classification used throughout the C--
|
|
| 56 | 56 | pipeline. This is a pair of a CmmCat and a Width.
|
| 57 | 57 | |
| 58 | - * 'CmmType.CmmCat': What the bits in a C-- value mean (e.g. a pointer, integer, or floating-point value)
|
|
| 58 | + * 'GHC.Cmm.Type.CmmCat': What the bits in a C-- value mean (e.g. a pointer, integer, or floating-point value)
|
|
| 59 | 59 | |
| 60 | - * 'CmmType.Width': The width of a C-- value.
|
|
| 60 | + * 'GHC.Cmm.Type.Width': The width of a C-- value.
|
|
| 61 | 61 | |
| 62 | - * 'CmmType.Length': The width (measured in number of scalars) of a vector value.
|
|
| 62 | + * 'GHC.Cmm.Type.Length': The width (measured in number of scalars) of a vector value.
|
|
| 63 | 63 | |
| 64 | 64 | * 'Format.Format': The data format representation used by much of the backend.
|
| 65 | 65 | |
| 66 | - * 'Format.ScalarFormat': The format of a 'Format.VecFormat'\'s scalar.
|
|
| 66 | + * 'GHC.CmmToAsm.Format.ScalarFormat': The format of a 'GHC.CmmToAsm.Format.VecFormat'\'s scalar.
|
|
| 67 | 67 | |
| 68 | - * 'RegClass.RegClass': Whether a register is an integer or a floating point/vector register.
|
|
| 68 | + * 'GHC.Platform.Reg.Class.RegClass': Whether a register is an integer or a floating point/vector register.
|
|
| 69 | 69 | -}
|
| 70 | 70 | |
| 71 | 71 | -- It looks very like the old MachRep, but it's now of purely local
|
| ... | ... | @@ -41,6 +41,7 @@ import GHC.Utils.Panic |
| 41 | 41 | import GHC.Types.SrcLoc
|
| 42 | 42 | import GHC.Types.Var.Set
|
| 43 | 43 | import GHC.Utils.Outputable
|
| 44 | +import GHC.Data.BooleanFormula () -- for BooleanFormulaDefault instance
|
|
| 44 | 45 | import Language.Haskell.Syntax.BooleanFormula ( BooleanFormula, mkTrue )
|
| 45 | 46 | |
| 46 | 47 | import qualified Data.Data as Data
|
| ... | ... | @@ -542,10 +542,11 @@ toIfGuidance src guidance |
| 542 | 542 | toIfaceBooleanFormula :: BF.BooleanFormula GhcRn -> IfaceBooleanFormula
|
| 543 | 543 | toIfaceBooleanFormula = go
|
| 544 | 544 | where
|
| 545 | - go (BF.Var nm ) = IfVar $ mkIfLclName . getOccFS . unLoc $ nm
|
|
| 546 | - go (BF.And bfs ) = IfAnd $ map (go . unLoc) bfs
|
|
| 547 | - go (BF.Or bfs ) = IfOr $ map (go . unLoc) bfs
|
|
| 548 | - go (BF.Parens bf) = IfParens $ (go . unLoc) bf
|
|
| 545 | + go (BF.Var _ nm ) = IfVar $ mkIfLclName . getOccFS . unLoc $ nm
|
|
| 546 | + go (BF.And _ bfs ) = IfAnd $ map (go . unLoc) bfs
|
|
| 547 | + go (BF.Or _ bfs ) = IfOr $ map (go . unLoc) bfs
|
|
| 548 | + go (BF.Parens _ bf) = IfParens $ (go . unLoc) bf
|
|
| 549 | + go (BF.XBooleanFormula _) = panic "toIfaceBooleanFormula"
|
|
| 549 | 550 | |
| 550 | 551 | {-
|
| 551 | 552 | ************************************************************************
|
| ... | ... | @@ -27,7 +27,10 @@ import GHC.Types.SrcLoc (unLoc) |
| 27 | 27 | import GHC.Utils.Outputable
|
| 28 | 28 | import GHC.Parser.Annotation ( SrcSpanAnnBF )
|
| 29 | 29 | import GHC.Hs.Extension (GhcPass (..), OutputableBndrId)
|
| 30 | -import Language.Haskell.Syntax.Extension (Anno, LIdP, IdP)
|
|
| 30 | +import Language.Haskell.Syntax.Extension (Anno, LIdP, IdP,
|
|
| 31 | + noExtField, NoExtField, DataConCantHappen,
|
|
| 32 | + XBFVar, XBFAnd, XBFOr, XBFParens,
|
|
| 33 | + XXBooleanFormula)
|
|
| 31 | 34 | import Language.Haskell.Syntax.BooleanFormula
|
| 32 | 35 | |
| 33 | 36 | |
| ... | ... | @@ -37,6 +40,17 @@ import Language.Haskell.Syntax.BooleanFormula |
| 37 | 40 | |
| 38 | 41 | type instance Anno (BooleanFormula (GhcPass p)) = SrcSpanAnnBF
|
| 39 | 42 | |
| 43 | +type instance XBFVar (GhcPass _) = NoExtField
|
|
| 44 | +type instance XBFAnd (GhcPass _) = NoExtField
|
|
| 45 | +type instance XBFOr (GhcPass _) = NoExtField
|
|
| 46 | +type instance XBFParens (GhcPass _) = NoExtField
|
|
| 47 | +type instance XXBooleanFormula (GhcPass _) = DataConCantHappen
|
|
| 48 | + |
|
| 49 | +instance BooleanFormulaDefault (GhcPass p) where
|
|
| 50 | + bfAnnAnd = noExtField
|
|
| 51 | + bfAnnOr = noExtField
|
|
| 52 | + |
|
| 53 | + |
|
| 40 | 54 | -- if we had Functor/Traversable (LbooleanFormula p) we could use that
|
| 41 | 55 | -- as a constraint and we wouldn't need to specialize to just GhcPass p,
|
| 42 | 56 | -- but becuase LBooleanFormula is a type synonym such a constraint is
|
| ... | ... | @@ -49,10 +63,10 @@ bfMap :: (LIdP (GhcPass p) -> LIdP (GhcPass p')) |
| 49 | 63 | -> BooleanFormula (GhcPass p) -> BooleanFormula (GhcPass p')
|
| 50 | 64 | bfMap f = go
|
| 51 | 65 | where
|
| 52 | - go (Var a ) = Var $ f a
|
|
| 53 | - go (And bfs) = And $ map (fmap go) bfs
|
|
| 54 | - go (Or bfs) = Or $ map (fmap go) bfs
|
|
| 55 | - go (Parens bf ) = Parens $ fmap go bf
|
|
| 66 | + go (Var x a ) = Var x $ f a
|
|
| 67 | + go (And x bfs) = And x $ map (fmap go) bfs
|
|
| 68 | + go (Or x bfs) = Or x $ map (fmap go) bfs
|
|
| 69 | + go (Parens x bf ) = Parens x $ fmap go bf
|
|
| 56 | 70 | |
| 57 | 71 | bfTraverse :: Applicative f
|
| 58 | 72 | => (LIdP (GhcPass p) -> f (LIdP (GhcPass p')))
|
| ... | ... | @@ -60,10 +74,10 @@ bfTraverse :: Applicative f |
| 60 | 74 | -> f (BooleanFormula (GhcPass p'))
|
| 61 | 75 | bfTraverse f = go
|
| 62 | 76 | where
|
| 63 | - go (Var a ) = Var <$> f a
|
|
| 64 | - go (And bfs) = And <$> traverse @[] (traverse go) bfs
|
|
| 65 | - go (Or bfs) = Or <$> traverse @[] (traverse go) bfs
|
|
| 66 | - go (Parens bf ) = Parens <$> traverse go bf
|
|
| 77 | + go (Var x a ) = Var x <$> f a
|
|
| 78 | + go (And x bfs) = And x <$> traverse @[] (traverse go) bfs
|
|
| 79 | + go (Or x bfs) = Or x <$> traverse @[] (traverse go) bfs
|
|
| 80 | + go (Parens x bf ) = Parens x <$> traverse go bf
|
|
| 67 | 81 | |
| 68 | 82 | |
| 69 | 83 | |
| ... | ... | @@ -106,18 +120,18 @@ We don't show a ridiculous error message like |
| 106 | 120 | ----------------------------------------------------------------------
|
| 107 | 121 | |
| 108 | 122 | isFalse :: BooleanFormula (GhcPass p) -> Bool
|
| 109 | -isFalse (Or []) = True
|
|
| 123 | +isFalse (Or _ []) = True
|
|
| 110 | 124 | isFalse _ = False
|
| 111 | 125 | |
| 112 | 126 | isTrue :: BooleanFormula (GhcPass p) -> Bool
|
| 113 | -isTrue (And []) = True
|
|
| 127 | +isTrue (And _ []) = True
|
|
| 114 | 128 | isTrue _ = False
|
| 115 | 129 | |
| 116 | 130 | eval :: (LIdP (GhcPass p) -> Bool) -> BooleanFormula (GhcPass p) -> Bool
|
| 117 | -eval f (Var x) = f x
|
|
| 118 | -eval f (And xs) = all (eval f . unLoc) xs
|
|
| 119 | -eval f (Or xs) = any (eval f . unLoc) xs
|
|
| 120 | -eval f (Parens x) = eval f (unLoc x)
|
|
| 131 | +eval f (Var _ x) = f x
|
|
| 132 | +eval f (And _ xs) = all (eval f . unLoc) xs
|
|
| 133 | +eval f (Or _ xs) = any (eval f . unLoc) xs
|
|
| 134 | +eval f (Parens _ x) = eval f (unLoc x)
|
|
| 121 | 135 | |
| 122 | 136 | -- Simplify a boolean formula.
|
| 123 | 137 | -- The argument function should give the truth of the atoms, or Nothing if undecided.
|
| ... | ... | @@ -125,12 +139,12 @@ simplify :: forall p. Eq (LIdP (GhcPass p)) |
| 125 | 139 | => (LIdP (GhcPass p) -> Maybe Bool)
|
| 126 | 140 | -> BooleanFormula (GhcPass p)
|
| 127 | 141 | -> BooleanFormula (GhcPass p)
|
| 128 | -simplify f (Var a) = case f a of
|
|
| 129 | - Nothing -> Var a
|
|
| 142 | +simplify f (Var x a) = case f a of
|
|
| 143 | + Nothing -> Var x a
|
|
| 130 | 144 | Just b -> mkBool b
|
| 131 | -simplify f (And xs) = mkAnd (map (fmap (simplify f)) xs)
|
|
| 132 | -simplify f (Or xs) = mkOr (map (fmap (simplify f)) xs)
|
|
| 133 | -simplify f (Parens x) = simplify f (unLoc x)
|
|
| 145 | +simplify f (And _ xs) = mkAnd (map (fmap (simplify f)) xs)
|
|
| 146 | +simplify f (Or _ xs) = mkOr (map (fmap (simplify f)) xs)
|
|
| 147 | +simplify f (Parens _ x) = simplify f (unLoc x)
|
|
| 134 | 148 | |
| 135 | 149 | -- Test if a boolean formula is satisfied when the given values are assigned to the atoms
|
| 136 | 150 | -- if it is, returns Nothing
|
| ... | ... | @@ -152,11 +166,11 @@ isUnsatisfied f bf |
| 152 | 166 | |
| 153 | 167 | -- If the boolean formula holds, does that mean that the given atom is always true?
|
| 154 | 168 | impliesAtom :: Eq (IdP (GhcPass p)) => BooleanFormula (GhcPass p) -> LIdP (GhcPass p) -> Bool
|
| 155 | -Var x `impliesAtom` y = (unLoc x) == (unLoc y)
|
|
| 156 | -And xs `impliesAtom` y = any (\x -> unLoc x `impliesAtom` y) xs
|
|
| 157 | - -- we have all of xs, so one of them implying y is enough
|
|
| 158 | -Or xs `impliesAtom` y = all (\x -> unLoc x `impliesAtom` y) xs
|
|
| 159 | -Parens x `impliesAtom` y = unLoc x `impliesAtom` y
|
|
| 169 | +Var _ x `impliesAtom` y = (unLoc x) == (unLoc y)
|
|
| 170 | +And _ xs `impliesAtom` y = any (\x -> unLoc x `impliesAtom` y) xs
|
|
| 171 | + -- we have all of xs, so one of them implying y is enough
|
|
| 172 | +Or _ xs `impliesAtom` y = all (\x -> unLoc x `impliesAtom` y) xs
|
|
| 173 | +Parens _ x `impliesAtom` y = unLoc x `impliesAtom` y
|
|
| 160 | 174 | |
| 161 | 175 | implies :: (Uniquable (IdP (GhcPass p))) => BooleanFormula (GhcPass p) -> BooleanFormula (GhcPass p) -> Bool
|
| 162 | 176 | implies e1 e2 = go (Clause emptyUniqSet [e1]) (Clause emptyUniqSet [e2])
|
| ... | ... | @@ -164,18 +178,18 @@ implies e1 e2 = go (Clause emptyUniqSet [e1]) (Clause emptyUniqSet [e2]) |
| 164 | 178 | go :: Uniquable (IdP (GhcPass p)) => Clause (GhcPass p) -> Clause (GhcPass p) -> Bool
|
| 165 | 179 | go l@Clause{ clauseExprs = hyp:hyps } r =
|
| 166 | 180 | case hyp of
|
| 167 | - Var x | memberClauseAtoms (unLoc x) r -> True
|
|
| 168 | - | otherwise -> go (extendClauseAtoms l (unLoc x)) { clauseExprs = hyps } r
|
|
| 169 | - Parens hyp' -> go l { clauseExprs = unLoc hyp':hyps } r
|
|
| 170 | - And hyps' -> go l { clauseExprs = map unLoc hyps' ++ hyps } r
|
|
| 171 | - Or hyps' -> all (\hyp' -> go l { clauseExprs = unLoc hyp':hyps } r) hyps'
|
|
| 181 | + Var _ x | memberClauseAtoms (unLoc x) r -> True
|
|
| 182 | + | otherwise -> go (extendClauseAtoms l (unLoc x)) { clauseExprs = hyps } r
|
|
| 183 | + Parens _ hyp' -> go l { clauseExprs = unLoc hyp':hyps } r
|
|
| 184 | + And _ hyps' -> go l { clauseExprs = map unLoc hyps' ++ hyps } r
|
|
| 185 | + Or _ hyps' -> all (\hyp' -> go l { clauseExprs = unLoc hyp':hyps } r) hyps'
|
|
| 172 | 186 | go l r@Clause{ clauseExprs = con:cons } =
|
| 173 | 187 | case con of
|
| 174 | - Var x | memberClauseAtoms (unLoc x) l -> True
|
|
| 175 | - | otherwise -> go l (extendClauseAtoms r (unLoc x)) { clauseExprs = cons }
|
|
| 176 | - Parens con' -> go l r { clauseExprs = unLoc con':cons }
|
|
| 177 | - And cons' -> all (\con' -> go l r { clauseExprs = unLoc con':cons }) cons'
|
|
| 178 | - Or cons' -> go l r { clauseExprs = map unLoc cons' ++ cons }
|
|
| 188 | + Var _ x | memberClauseAtoms (unLoc x) l -> True
|
|
| 189 | + | otherwise -> go l (extendClauseAtoms r (unLoc x)) { clauseExprs = cons }
|
|
| 190 | + Parens _ con' -> go l r { clauseExprs = unLoc con':cons }
|
|
| 191 | + And _ cons' -> all (\con' -> go l r { clauseExprs = unLoc con':cons }) cons'
|
|
| 192 | + Or _ cons' -> go l r { clauseExprs = map unLoc cons' ++ cons }
|
|
| 179 | 193 | go _ _ = False
|
| 180 | 194 | |
| 181 | 195 | -- A small sequent calculus proof engine.
|
| ... | ... | @@ -201,12 +215,12 @@ pprBooleanFormula' :: (Rational -> LIdP (GhcPass p) -> SDoc) |
| 201 | 215 | -> Rational -> BooleanFormula (GhcPass p) -> SDoc
|
| 202 | 216 | pprBooleanFormula' pprVar pprAnd pprOr = go
|
| 203 | 217 | where
|
| 204 | - go p (Var x) = pprVar p x
|
|
| 205 | - go p (And []) = cparen (p > 0) empty
|
|
| 206 | - go p (And xs) = pprAnd p (map (go 3 . unLoc) xs)
|
|
| 207 | - go _ (Or []) = keyword $ text "FALSE"
|
|
| 208 | - go p (Or xs) = pprOr p (map (go 2 . unLoc) xs)
|
|
| 209 | - go p (Parens x) = go p (unLoc x)
|
|
| 218 | + go p (Var _ x) = pprVar p x
|
|
| 219 | + go p (And _ []) = cparen (p > 0) empty
|
|
| 220 | + go p (And _ xs) = pprAnd p (map (go 3 . unLoc) xs)
|
|
| 221 | + go _ (Or _ []) = keyword $ text "FALSE"
|
|
| 222 | + go p (Or _ xs) = pprOr p (map (go 2 . unLoc) xs)
|
|
| 223 | + go p (Parens _ x) = go p (unLoc x)
|
|
| 210 | 224 | |
| 211 | 225 | -- Pretty print in source syntax, "a | b | c,d,e"
|
| 212 | 226 | pprBooleanFormula :: (Rational -> LIdP (GhcPass p) -> SDoc)
|
| ... | ... | @@ -233,8 +247,9 @@ instance OutputableBndrId p => Outputable (BooleanFormula (GhcPass p)) where |
| 233 | 247 | pprBooleanFormulaNormal :: OutputableBndrId p => BooleanFormula (GhcPass p) -> SDoc
|
| 234 | 248 | pprBooleanFormulaNormal = go
|
| 235 | 249 | where
|
| 236 | - go (Var x) = pprPrefixOcc (unLoc x)
|
|
| 237 | - go (And xs) = fsep $ punctuate comma (map (go . unLoc) xs)
|
|
| 238 | - go (Or []) = keyword $ text "FALSE"
|
|
| 239 | - go (Or xs) = fsep $ intersperse vbar (map (go . unLoc) xs)
|
|
| 240 | - go (Parens x) = parens (go $ unLoc x) |
|
| 250 | + go (Var _ x) = pprPrefixOcc (unLoc x)
|
|
| 251 | + go (And _ xs) = fsep $ punctuate comma (map (go . unLoc) xs)
|
|
| 252 | + go (Or _ []) = keyword $ text "FALSE"
|
|
| 253 | + go (Or _ xs) = fsep $ intersperse vbar (map (go . unLoc) xs)
|
|
| 254 | + go (Parens _ x) = parens (go $ unLoc x)
|
|
| 255 | + go (XBooleanFormula _) = text "XBooleanFormula" |
| ... | ... | @@ -72,6 +72,7 @@ module GHC.Data.Word64Map.Internal ( |
| 72 | 72 | -- * Query
|
| 73 | 73 | , null
|
| 74 | 74 | , size
|
| 75 | + , sizeAtMost
|
|
| 75 | 76 | , compareSize
|
| 76 | 77 | , member
|
| 77 | 78 | , notMember
|
| ... | ... | @@ -533,6 +534,10 @@ size = go 0 |
| 533 | 534 | go acc (Tip _ _) = 1 + acc
|
| 534 | 535 | go acc Nil = acc
|
| 535 | 536 | |
| 537 | +-- | Check if the map is <= n in O(min(|map|,n))
|
|
| 538 | +sizeAtMost :: Word64Map a -> Int -> Bool
|
|
| 539 | +sizeAtMost map n = compareSize map n /= GT
|
|
| 540 | + |
|
| 536 | 541 | -- | \(O(\min(n,c))\). Compare the number of entries in the map to an @Int@.
|
| 537 | 542 | --
|
| 538 | 543 | -- @compareSize m c@ returns the same result as @compare ('size' m) c@ but is
|
| ... | ... | @@ -113,6 +113,7 @@ module GHC.Data.Word64Map.Lazy ( |
| 113 | 113 | -- ** Size
|
| 114 | 114 | , WM.null
|
| 115 | 115 | , size
|
| 116 | + , sizeAtMost
|
|
| 116 | 117 | , compareSize
|
| 117 | 118 | |
| 118 | 119 | -- * Combine
|
| ... | ... | @@ -130,6 +130,7 @@ module GHC.Data.Word64Map.Strict ( |
| 130 | 130 | -- ** Size
|
| 131 | 131 | , null
|
| 132 | 132 | , size
|
| 133 | + , sizeAtMost
|
|
| 133 | 134 | , compareSize
|
| 134 | 135 | |
| 135 | 136 | -- * Combine
|
| ... | ... | @@ -132,6 +132,7 @@ module GHC.Data.Word64Map.Strict.Internal ( |
| 132 | 132 | -- ** Size
|
| 133 | 133 | , null
|
| 134 | 134 | , size
|
| 135 | + , sizeAtMost
|
|
| 135 | 136 | , compareSize
|
| 136 | 137 | |
| 137 | 138 | -- * Combine
|
| ... | ... | @@ -324,6 +325,7 @@ import GHC.Data.Word64Map.Internal |
| 324 | 325 | , spanAntitone
|
| 325 | 326 | , restrictKeys
|
| 326 | 327 | , size
|
| 328 | + , sizeAtMost
|
|
| 327 | 329 | , compareSize
|
| 328 | 330 | , split
|
| 329 | 331 | , splitLookup
|
| ... | ... | @@ -62,7 +62,7 @@ looking up source locations for stack info tables in the map generated during th |
| 62 | 62 | |
| 63 | 63 | The rest of this note will document exactly how the first pass generates the map from labels to
|
| 64 | 64 | estimated source positions. The algorithms are different depending on whether tables-next-to-code
|
| 65 | -is on or off. Both algorithms have in common that we are looking for a `CmmNode.CmmTick`
|
|
| 65 | +is on or off. Both algorithms have in common that we are looking for a `GHC.Cmm.Node.CmmTick`
|
|
| 66 | 66 | (containing a `SourceNote`) that is near what we estimate to be the label of a return stack frame.
|
| 67 | 67 | |
| 68 | 68 | With tables-next-to-code
|
| ... | ... | @@ -112,14 +112,14 @@ open or closed on exit (one can fallthrough from them to the next node). |
| 112 | 112 | Please refer to the paper "Hoopl: A Modular, Reusable Library for Dataflow Analysis and Transformation"
|
| 113 | 113 | for a detailed explanation.
|
| 114 | 114 | |
| 115 | -Here we use the fact, that calls (represented by `CmmNode.CmmCall`) are always closed on exit
|
|
| 115 | +Here we use the fact, that calls (represented by `GHC.Cmm.Node.CmmCall`) are always closed on exit
|
|
| 116 | 116 | (`CmmNode O C`, `O` means open, `C` closed). In other words, they are always at the end of a block.
|
| 117 | 117 | |
| 118 | 118 | So, given a `CmmGraph`:
|
| 119 | - - Look at the end of every block: If it is a `CmmNode.CmmCall` returning to some label, lookup
|
|
| 120 | - the nearest `CmmNode.CmmTick` by traversing the middle part of the block backwards (from end to
|
|
| 119 | + - Look at the end of every block: If it is a `GHC.Cmm.Node.CmmCall` returning to some label, lookup
|
|
| 120 | + the nearest `GHC.Cmm.Node.CmmTick` by traversing the middle part of the block backwards (from end to
|
|
| 121 | 121 | beginning).
|
| 122 | - - Take the first `CmmNode.CmmTick` that contains a `Tickish.SourceNote` and map the label we
|
|
| 122 | + - Take the first `GHC.Cmm.Node.CmmTick` that contains a `Tickish.SourceNote` and map the label we
|
|
| 123 | 123 | found to it's payload as an `IpeSourceLocation`. (There are other `Tickish` constructors like
|
| 124 | 124 | `ProfNote` or `HpcTick`, these are ignored.)
|
| 125 | 125 |
| ... | ... | @@ -2083,16 +2083,16 @@ instance ToHie PendingRnSplice where |
| 2083 | 2083 | instance (HiePass p, Data (IdGhcP p))
|
| 2084 | 2084 | => ToHie (GenLocated SrcSpanAnnBF (BooleanFormula (GhcPass p))) where
|
| 2085 | 2085 | toHie (L span form) = concatM $ makeNode form (locA span) : case form of
|
| 2086 | - Var a ->
|
|
| 2086 | + Var _ a ->
|
|
| 2087 | 2087 | [ toHie $ C Use a
|
| 2088 | 2088 | ]
|
| 2089 | - And forms ->
|
|
| 2089 | + And _ forms ->
|
|
| 2090 | 2090 | [ toHie forms
|
| 2091 | 2091 | ]
|
| 2092 | - Or forms ->
|
|
| 2092 | + Or _ forms ->
|
|
| 2093 | 2093 | [ toHie forms
|
| 2094 | 2094 | ]
|
| 2095 | - Parens f ->
|
|
| 2095 | + Parens _ f ->
|
|
| 2096 | 2096 | [ toHie f
|
| 2097 | 2097 | ]
|
| 2098 | 2098 |
| ... | ... | @@ -103,6 +103,7 @@ import GHC.Data.FastString |
| 103 | 103 | import GHC.Data.BooleanFormula (pprBooleanFormula, isTrue)
|
| 104 | 104 | |
| 105 | 105 | import Language.Haskell.Syntax.BooleanFormula(BooleanFormula(..))
|
| 106 | +import Language.Haskell.Syntax.Extension (noExtField)
|
|
| 106 | 107 | import Language.Haskell.Syntax.Text
|
| 107 | 108 | |
| 108 | 109 | import Control.Monad
|
| ... | ... | @@ -1326,10 +1327,10 @@ pprIfaceDecl ss decl@(IfaceClass { ifName = clas |
| 1326 | 1327 | |
| 1327 | 1328 | fromIfaceBooleanFormula :: IfaceBooleanFormula -> BooleanFormula GhcRn
|
| 1328 | 1329 | -- `mkUnboundName` here is fine because the Name generated is only used for pretty printing and nothing else.
|
| 1329 | - fromIfaceBooleanFormula (IfVar nm ) = Var $ noLocA . mkUnboundName . mkVarOccFS . ifLclNameFS $ nm
|
|
| 1330 | - fromIfaceBooleanFormula (IfAnd bfs ) = And $ map (noLocA . fromIfaceBooleanFormula) bfs
|
|
| 1331 | - fromIfaceBooleanFormula (IfOr bfs ) = Or $ map (noLocA . fromIfaceBooleanFormula) bfs
|
|
| 1332 | - fromIfaceBooleanFormula (IfParens bf) = Parens $ (noLocA . fromIfaceBooleanFormula) bf
|
|
| 1330 | + fromIfaceBooleanFormula (IfVar nm ) = Var noExtField $ noLocA . mkUnboundName . mkVarOccFS . ifLclNameFS $ nm
|
|
| 1331 | + fromIfaceBooleanFormula (IfAnd bfs ) = And noExtField $ map (noLocA . fromIfaceBooleanFormula) bfs
|
|
| 1332 | + fromIfaceBooleanFormula (IfOr bfs ) = Or noExtField $ map (noLocA . fromIfaceBooleanFormula) bfs
|
|
| 1333 | + fromIfaceBooleanFormula (IfParens bf) = Parens noExtField $ (noLocA . fromIfaceBooleanFormula) bf
|
|
| 1333 | 1334 | |
| 1334 | 1335 | |
| 1335 | 1336 | -- See Note [Suppressing binder signatures] in GHC.Iface.Type
|
| ... | ... | @@ -82,7 +82,7 @@ Here is a running example: |
| 82 | 82 | |
| 83 | 83 | (SF4) The desugarer replaces a nested expression (static e) with a top-level
|
| 84 | 84 | binding for an application of the function 'makeStatic' (defined in module
|
| 85 | - GHC.StaticPtr.Internal of base). So we get
|
|
| 85 | + GHC.Internal.StaticPtr.Internal of base). So we get
|
|
| 86 | 86 | |
| 87 | 87 | s = /\abc. makeStatic location e
|
| 88 | 88 | f x = ...(fromStaticPtr s)...
|
| ... | ... | @@ -883,10 +883,10 @@ tc_iface_decl _parent ignore_prags |
| 883 | 883 | return (ATI tc mb_def)
|
| 884 | 884 | |
| 885 | 885 | tc_boolean_formula :: IfaceBooleanFormula -> IfL (BooleanFormula GhcRn)
|
| 886 | - tc_boolean_formula (IfAnd ibfs ) = BF.And . map noLocA <$> traverse tc_boolean_formula ibfs
|
|
| 887 | - tc_boolean_formula (IfOr ibfs ) = BF.Or . map noLocA <$> traverse tc_boolean_formula ibfs
|
|
| 888 | - tc_boolean_formula (IfParens ibf) = BF.Parens . noLocA <$> tc_boolean_formula ibf
|
|
| 889 | - tc_boolean_formula (IfVar nm ) = BF.Var . noLocA <$> (lookupIfaceTop . mkVarOccFS . ifLclNameFS $ nm)
|
|
| 886 | + tc_boolean_formula (IfAnd ibfs ) = BF.And NoExtField . map noLocA <$> traverse tc_boolean_formula ibfs
|
|
| 887 | + tc_boolean_formula (IfOr ibfs ) = BF.Or NoExtField . map noLocA <$> traverse tc_boolean_formula ibfs
|
|
| 888 | + tc_boolean_formula (IfParens ibf) = BF.Parens NoExtField . noLocA <$> tc_boolean_formula ibf
|
|
| 889 | + tc_boolean_formula (IfVar nm ) = BF.Var NoExtField . noLocA <$> (lookupIfaceTop . mkVarOccFS . ifLclNameFS $ nm)
|
|
| 890 | 890 | |
| 891 | 891 | mk_sc_doc pred = text "Superclass" <+> ppr pred
|
| 892 | 892 | mk_at_doc tc = text "Associated type" <+> ppr tc
|
| ... | ... | @@ -3821,11 +3821,11 @@ name_boolformula :: { LBooleanFormula GhcPs } |
| 3821 | 3821 | : name_boolformula_and { $1 }
|
| 3822 | 3822 | | name_boolformula_and '|' name_boolformula
|
| 3823 | 3823 | {% do { h <- addTrailingVbarBF $1 (epTok $2)
|
| 3824 | - ; return (sLLa $1 $> (Or [h,$3])) } }
|
|
| 3824 | + ; return (sLLa $1 $> (Or noExtField [h,$3])) } }
|
|
| 3825 | 3825 | |
| 3826 | 3826 | name_boolformula_and :: { LBooleanFormula GhcPs }
|
| 3827 | 3827 | : name_boolformula_and_list
|
| 3828 | - { sLLa (head $1) (last $1) (And (toList $1)) }
|
|
| 3828 | + { sLLa (head $1) (last $1) (And noExtField (toList $1)) }
|
|
| 3829 | 3829 | |
| 3830 | 3830 | name_boolformula_and_list :: { NonEmpty (LBooleanFormula GhcPs) }
|
| 3831 | 3831 | : name_boolformula_atom { NE.singleton $1 }
|
| ... | ... | @@ -3834,9 +3834,9 @@ name_boolformula_and_list :: { NonEmpty (LBooleanFormula GhcPs) } |
| 3834 | 3834 | ; return (h NE.<| $3) } }
|
| 3835 | 3835 | |
| 3836 | 3836 | name_boolformula_atom :: { LBooleanFormula GhcPs }
|
| 3837 | - : '(' name_boolformula ')' {% amsr (sLL $1 $> (Parens $2))
|
|
| 3837 | + : '(' name_boolformula ')' {% amsr (sLL $1 $> (Parens noExtField $2))
|
|
| 3838 | 3838 | (AnnBooleanFormula (epTok $1) (epTok $3) []) }
|
| 3839 | - | name_var { sL1a $1 (Var $1) }
|
|
| 3839 | + | name_var { sL1a $1 (Var noExtField $1) }
|
|
| 3840 | 3840 | |
| 3841 | 3841 | namelist :: { Located [LocatedN RdrName] }
|
| 3842 | 3842 | namelist : name_var { sL1 $1 [$1] }
|
| ... | ... | @@ -460,7 +460,7 @@ In implementation terms |
| 460 | 460 | - It is only called when applying an instance decl,
|
| 461 | 461 | in GHC.Tc.Solver.Dict.tryInstances
|
| 462 | 462 | |
| 463 | - - ClsInst.InstanceWhat says what kind of instance was
|
|
| 463 | + - GHC.Tc.Instance.Class.InstanceWhat says what kind of instance was
|
|
| 464 | 464 | used to solve the constraint. In particular
|
| 465 | 465 | * LocalInstance identifies quantified constraints
|
| 466 | 466 | * BuiltinEqInstance identifies the strange built-in
|
| ... | ... | @@ -800,7 +800,7 @@ The InertCans represents a collection of constraints with the following properti |
| 800 | 800 | eg a wanted cannot rewrite a given)
|
| 801 | 801 | |
| 802 | 802 | * CEqCan equalities: see Note [inert_eqs: the inert equalities]
|
| 803 | - Also see documentation in Constraint.Ct for a list of invariants
|
|
| 803 | + Also see documentation in GHC.Tc.Types.Constraint.Ct for a list of invariants
|
|
| 804 | 804 | |
| 805 | 805 | Note [inert_eqs: the inert equalities]
|
| 806 | 806 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -345,7 +345,7 @@ tcClassMinimalDef _clas sigs op_info |
| 345 | 345 | where
|
| 346 | 346 | -- By default require all methods without a default implementation
|
| 347 | 347 | defMindef :: ClassMinimalDef
|
| 348 | - defMindef = mkAnd [ noLocA (mkVar (noLocA name))
|
|
| 348 | + defMindef = mkAnd [ noLocA (mkVar NoExtField (noLocA name))
|
|
| 349 | 349 | | (name, _, Nothing) <- op_info ]
|
| 350 | 350 | |
| 351 | 351 | instantiateMethod :: Class -> TcId -> [TcType] -> TcType
|
| ... | ... | @@ -987,7 +987,7 @@ until the final simplifier phase; see Note [Activation for data |
| 987 | 987 | constructor wrappers].
|
| 988 | 988 | |
| 989 | 989 | For further reading, see:
|
| 990 | - * (IA1) in Note [Interesting arguments] in GHC.Core.Op.Simplify.Utils
|
|
| 990 | + * (IA1) in Note [Interesting arguments] in GHC.Core.Opt.Simplify.Utils
|
|
| 991 | 991 | * Note [Lone variables] in GHC.Core.Unfold
|
| 992 | 992 | * Note [exprIsConApp_maybe on data constructors with wrappers]
|
| 993 | 993 | in GHC.Core.SimpleOpt
|
| ... | ... | @@ -351,8 +351,8 @@ foldUDFM :: (elt -> a -> a) -> a -> UniqDFM key elt -> a |
| 351 | 351 | {-# INLINE foldUDFM #-}
|
| 352 | 352 | -- Specialises k and z into M.foldr on the small-map path.
|
| 353 | 353 | foldUDFM k z (UDFM m ub)
|
| 354 | - | M.compareSize m 1 /= GT = M.foldr (k . taggedFst) z m
|
|
| 355 | - | otherwise = fold_udfm k z m ub
|
|
| 354 | + | M.sizeAtMost m 1 = M.foldr (k . taggedFst) z m
|
|
| 355 | + | otherwise = fold_udfm k z m ub
|
|
| 356 | 356 | |
| 357 | 357 | fold_udfm :: (elt -> a -> a) -> a -> M.Word64Map (TaggedVal elt) -> Int -> a
|
| 358 | 358 | {-# NOINLINE fold_udfm #-}
|
| ... | ... | @@ -402,8 +402,8 @@ eltsUDFM :: UniqDFM key elt -> [elt] |
| 402 | 402 | {-# INLINE eltsUDFM #-} -- so the small case is a good producer
|
| 403 | 403 | -- This matters for T13719.
|
| 404 | 404 | eltsUDFM (UDFM m ub)
|
| 405 | - | M.compareSize m 1 /= GT = build (\c n -> M.foldr (c . taggedFst) n m)
|
|
| 406 | - | otherwise = elts_udfm m ub
|
|
| 405 | + | M.sizeAtMost m 1 = build (\c n -> M.foldr (c . taggedFst) n m)
|
|
| 406 | + | otherwise = elts_udfm m ub
|
|
| 407 | 407 | |
| 408 | 408 | elts_udfm :: M.Word64Map (TaggedVal elt) -> Int -> [elt]
|
| 409 | 409 | {-# NOINLINE elts_udfm #-}
|
| ... | ... | @@ -511,7 +511,7 @@ udfmToList :: UniqDFM key elt -> [(Unique, elt)] |
| 511 | 511 | -- traverseUSDFM in the pattern-match checker, which doesn't fuse. Inlining
|
| 512 | 512 | -- the size dispatch into it regresses T17836.
|
| 513 | 513 | udfmToList (UDFM m ub)
|
| 514 | - | M.compareSize m 1 /= GT =
|
|
| 514 | + | M.sizeAtMost m 1 =
|
|
| 515 | 515 | M.foldrWithKey (\k tv r -> (mkUniqueGrimily k, taggedFst tv) : r) [] m
|
| 516 | 516 | | usePigeonholeSort m ub = pigeonholeSort ub
|
| 517 | 517 | (\k tv -> TaggedVal (mkUniqueGrimily k, taggedFst tv) (taggedSnd tv)) m
|
| ... | ... | @@ -621,27 +621,27 @@ Note [Types for coercions, predicates, and evidence] |
| 621 | 621 | VarBndr is polymorphic in both var and visibility fields.
|
| 622 | 622 | Currently there are nine different uses of 'VarBndr':
|
| 623 | 623 | |
| 624 | -* Var.ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag
|
|
| 624 | +* GHC.Types.Var.ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag
|
|
| 625 | 625 | Binder of a forall-type; see ForAllTy in GHC.Core.TyCo.Rep
|
| 626 | 626 | |
| 627 | -* Var.TyVarBinder = VarBndr TyVar ForAllTyFlag
|
|
| 627 | +* GHC.Types.Var.TyVarBinder = VarBndr TyVar ForAllTyFlag
|
|
| 628 | 628 | Subset of ForAllTyBinder when we are sure the binder is a TyVar
|
| 629 | 629 | |
| 630 | -* Var.InvisTVBinder = VarBndr TyVar Specificity
|
|
| 630 | +* GHC.Types.Var.InvisTVBinder = VarBndr TyVar Specificity
|
|
| 631 | 631 | Specialised form of TyVarBinder, when ForAllTyFlag = Invisible s
|
| 632 | 632 | See GHC.Core.Type.splitForAllInvisTVBinders
|
| 633 | 633 | |
| 634 | -* Var.ReqTVBinder = VarBndr TyVar ()
|
|
| 634 | +* GHC.Types.Var.ReqTVBinder = VarBndr TyVar ()
|
|
| 635 | 635 | Specialised form of TyVarBinder, when ForAllTyFlag = Required
|
| 636 | 636 | See GHC.Core.Type.splitForAllReqTVBinders
|
| 637 | 637 | This one is barely used
|
| 638 | 638 | |
| 639 | -* TyCon.TyConBinder = VarBndr TyVar TyConBndrVis
|
|
| 639 | +* GHC.Core.TyCon.TyConBinder = VarBndr TyVar TyConBndrVis
|
|
| 640 | 640 | Binders of a TyCon; see TyCon in GHC.Core.TyCon
|
| 641 | 641 | |
| 642 | -* IfaceType.IfaceForAllBndr = VarBndr IfaceBndr ForAllTyFlag
|
|
| 643 | -* IfaceType.IfaceForAllSpecBndr = VarBndr IfaceBndr Specificity
|
|
| 644 | -* IfaceType.IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis
|
|
| 642 | +* GHC.Iface.Type.IfaceForAllBndr = VarBndr IfaceBndr ForAllTyFlag
|
|
| 643 | +* GHC.Iface.Type.IfaceForAllSpecBndr = VarBndr IfaceBndr Specificity
|
|
| 644 | +* GHC.Iface.Type.IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis
|
|
| 645 | 645 | -}
|
| 646 | 646 | |
| 647 | 647 | data VarBndr var argf = Bndr var argf
|
| ... | ... | @@ -4,59 +4,78 @@ |
| 4 | 4 | |
| 5 | 5 | module Language.Haskell.Syntax.BooleanFormula(
|
| 6 | 6 | BooleanFormula(..), LBooleanFormula,
|
| 7 | - mkVar, mkFalse, mkTrue, mkBool, mkAnd, mkOr
|
|
| 7 | + mkVar, mkFalse, mkTrue, mkBool, mkAnd, mkOr,
|
|
| 8 | + BooleanFormulaDefault(..)
|
|
| 8 | 9 | ) where
|
| 9 | 10 | |
| 10 | 11 | import Prelude hiding ( init, last )
|
| 11 | 12 | import Data.List ( nub )
|
| 12 | -import Language.Haskell.Syntax.Extension (XRec, UnXRec (..), LIdP)
|
|
| 13 | +import Language.Haskell.Syntax.Extension (XRec, UnXRec (..), LIdP,
|
|
| 14 | + XBFVar, XBFAnd, XBFOr, XBFParens,
|
|
| 15 | + XXBooleanFormula)
|
|
| 13 | 16 | |
| 14 | 17 | |
| 15 | 18 | -- types
|
| 16 | 19 | type LBooleanFormula p = XRec p (BooleanFormula p)
|
| 17 | -data BooleanFormula p = Var (LIdP p) | And [LBooleanFormula p] | Or [LBooleanFormula p]
|
|
| 18 | - | Parens (LBooleanFormula p)
|
|
| 20 | +data BooleanFormula p
|
|
| 21 | + = Var (XBFVar p) (LIdP p)
|
|
| 22 | + | And (XBFAnd p) [LBooleanFormula p]
|
|
| 23 | + | Or (XBFOr p) [LBooleanFormula p]
|
|
| 24 | + | Parens (XBFParens p) (LBooleanFormula p)
|
|
| 25 | + | XBooleanFormula !(XXBooleanFormula p)
|
|
| 26 | + |
|
| 27 | +class BooleanFormulaDefault p where
|
|
| 28 | + bfAnnAnd :: XBFAnd p
|
|
| 29 | + bfAnnOr :: XBFOr p
|
|
| 19 | 30 | |
| 20 | 31 | -- instances
|
| 21 | -deriving instance (Eq (LIdP p), Eq (LBooleanFormula p)) => Eq (BooleanFormula p)
|
|
| 32 | +deriving instance (Eq (LIdP p), Eq (LBooleanFormula p),
|
|
| 33 | + Eq (XBFVar p),
|
|
| 34 | + Eq (XBFAnd p),
|
|
| 35 | + Eq (XBFOr p),
|
|
| 36 | + Eq (XBFParens p),
|
|
| 37 | + Eq (XXBooleanFormula p)
|
|
| 38 | + ) => Eq (BooleanFormula p)
|
|
| 22 | 39 | |
| 23 | 40 | -- smart constructors
|
| 24 | 41 | -- see note [Simplification of BooleanFormulas]
|
| 25 | -mkVar :: LIdP p -> BooleanFormula p
|
|
| 42 | +mkVar :: XBFVar p -> LIdP p -> BooleanFormula p
|
|
| 26 | 43 | mkVar = Var
|
| 27 | 44 | |
| 28 | -mkFalse, mkTrue :: BooleanFormula p
|
|
| 29 | -mkFalse = Or []
|
|
| 30 | -mkTrue = And []
|
|
| 45 | +mkFalse, mkTrue :: forall p. BooleanFormulaDefault p => BooleanFormula p
|
|
| 46 | +mkFalse = Or (bfAnnOr @p) []
|
|
| 47 | +mkTrue = And (bfAnnAnd @p) []
|
|
| 31 | 48 | |
| 32 | 49 | -- Convert a Bool to a BooleanFormula
|
| 33 | -mkBool :: Bool -> BooleanFormula p
|
|
| 50 | +mkBool :: BooleanFormulaDefault p => Bool -> BooleanFormula p
|
|
| 34 | 51 | mkBool False = mkFalse
|
| 35 | 52 | mkBool True = mkTrue
|
| 36 | 53 | |
| 37 | 54 | -- Make a conjunction, and try to simplify
|
| 38 | -mkAnd :: forall p. (UnXRec p, Eq (LIdP p), Eq (LBooleanFormula p)) => [LBooleanFormula p] -> BooleanFormula p
|
|
| 55 | +mkAnd :: forall p. (UnXRec p, Eq (LIdP p), Eq (LBooleanFormula p), BooleanFormulaDefault p)
|
|
| 56 | + => [LBooleanFormula p] -> BooleanFormula p
|
|
| 39 | 57 | mkAnd = maybe mkFalse (mkAnd' . nub . concat) . mapM fromAnd
|
| 40 | 58 | where
|
| 41 | 59 | -- See Note [Simplification of BooleanFormulas]
|
| 42 | 60 | fromAnd :: LBooleanFormula p -> Maybe [LBooleanFormula p]
|
| 43 | 61 | fromAnd bf = case unXRec @p bf of
|
| 44 | - (And xs) -> Just xs
|
|
| 62 | + (And _ xs) -> Just xs
|
|
| 45 | 63 | -- assume that xs are already simplified
|
| 46 | 64 | -- otherwise we would need: fromAnd (And xs) = concat <$> traverse fromAnd xs
|
| 47 | - (Or []) -> Nothing
|
|
| 65 | + (Or _ []) -> Nothing
|
|
| 48 | 66 | -- in case of False we bail out, And [..,mkFalse,..] == mkFalse
|
| 49 | 67 | _ -> Just [bf]
|
| 50 | 68 | mkAnd' [x] = unXRec @p x
|
| 51 | - mkAnd' xs = And xs
|
|
| 69 | + mkAnd' xs = And (bfAnnAnd @p) xs
|
|
| 52 | 70 | |
| 53 | -mkOr :: forall p. (UnXRec p, Eq (LIdP p), Eq (LBooleanFormula p)) => [LBooleanFormula p] -> BooleanFormula p
|
|
| 71 | +mkOr :: forall p. (UnXRec p, Eq (LIdP p), Eq (LBooleanFormula p), BooleanFormulaDefault p)
|
|
| 72 | + => [LBooleanFormula p] -> BooleanFormula p
|
|
| 54 | 73 | mkOr = maybe mkTrue (mkOr' . nub . concat) . mapM fromOr
|
| 55 | 74 | where
|
| 56 | 75 | -- See Note [Simplification of BooleanFormulas]
|
| 57 | 76 | fromOr bf = case unXRec @p bf of
|
| 58 | - (Or xs) -> Just xs
|
|
| 59 | - (And []) -> Nothing
|
|
| 60 | - _ -> Just [bf]
|
|
| 77 | + (Or _ xs) -> Just xs
|
|
| 78 | + (And _ []) -> Nothing
|
|
| 79 | + _ -> Just [bf]
|
|
| 61 | 80 | mkOr' [x] = unXRec @p x
|
| 62 | - mkOr' xs = Or xs |
|
| 81 | + mkOr' xs = Or (bfAnnOr @p) xs |
| ... | ... | @@ -841,6 +841,14 @@ type family XXIntegralLit x |
| 841 | 841 | type family XStringLit x
|
| 842 | 842 | type family XXStringLit x
|
| 843 | 843 | |
| 844 | +-- =====================================================================
|
|
| 845 | +-- BooleanFormula type families
|
|
| 846 | + |
|
| 847 | +type family XBFVar p
|
|
| 848 | +type family XBFAnd p
|
|
| 849 | +type family XBFOr p
|
|
| 850 | +type family XBFParens p
|
|
| 851 | +type family XXBooleanFormula p
|
|
| 844 | 852 | |
| 845 | 853 | -- =====================================================================
|
| 846 | 854 | -- Misc
|
| ... | ... | @@ -11,7 +11,7 @@ main = do |
| 11 | 11 | let script = intercalate " "
|
| 12 | 12 | [ "exec python3 2>/dev/null"
|
| 13 | 13 | , "-c"
|
| 14 | - , "'import os; os.kill(os.getpid(), 1)'"
|
|
| 14 | + , "'import os; os.kill(os.getpid(), 9)'" -- SIGKILL
|
|
| 15 | 15 | ]
|
| 16 | 16 | (_,_,_,p) <- createProcess (shell script)
|
| 17 | 17 | waitForProcess p >>= print
|
| 1 | -ExitFailure (-1)
|
|
| 2 | -Just (ExitFailure (-1))
|
|
| 3 | -Just (ExitFailure (-1)) |
|
| 1 | +ExitFailure (-9)
|
|
| 2 | +Just (ExitFailure (-9))
|
|
| 3 | +Just (ExitFailure (-9)) |
| ... | ... | @@ -2722,18 +2722,18 @@ instance ExactPrint (BF.BooleanFormula GhcPs) where |
| 2722 | 2722 | getAnnotationEntry = const NoEntryVal
|
| 2723 | 2723 | setAnnotationAnchor a _ _ _ = a
|
| 2724 | 2724 | |
| 2725 | - exact (BF.Var x) = do
|
|
| 2725 | + exact (BF.Var e x) = do
|
|
| 2726 | 2726 | x' <- markAnnotated x
|
| 2727 | - return (BF.Var x')
|
|
| 2728 | - exact (BF.Or ls) = do
|
|
| 2727 | + return (BF.Var e x')
|
|
| 2728 | + exact (BF.Or e ls) = do
|
|
| 2729 | 2729 | ls' <- mapM markAnnotated ls
|
| 2730 | - return (BF.Or ls')
|
|
| 2731 | - exact (BF.And ls) = do
|
|
| 2730 | + return (BF.Or e ls')
|
|
| 2731 | + exact (BF.And e ls) = do
|
|
| 2732 | 2732 | ls' <- mapM markAnnotated ls
|
| 2733 | - return (BF.And ls')
|
|
| 2734 | - exact (BF.Parens x) = do
|
|
| 2733 | + return (BF.And e ls')
|
|
| 2734 | + exact (BF.Parens e x) = do
|
|
| 2735 | 2735 | x' <- markAnnotated x
|
| 2736 | - return (BF.Parens x')
|
|
| 2736 | + return (BF.Parens e x')
|
|
| 2737 | 2737 | |
| 2738 | 2738 | -- ---------------------------------------------------------------------
|
| 2739 | 2739 |
| ... | ... | @@ -998,26 +998,26 @@ ppClassDecl |
| 998 | 998 | -- Minimal complete definition
|
| 999 | 999 | minimalBit = case [s | MinimalSig _ (L _ s) <- sigs] of
|
| 1000 | 1000 | -- Miminal complete definition = every shown method
|
| 1001 | - And xs : _
|
|
| 1002 | - | sort [getName n | L _ (Var (L _ n)) <- xs]
|
|
| 1001 | + And _ xs : _
|
|
| 1002 | + | sort [getName n | L _ (Var _ (L _ n)) <- xs]
|
|
| 1003 | 1003 | == sort [getName n | ClassOpSig _ _ ns _ <- sigs, L _ n <- ns] ->
|
| 1004 | 1004 | noHtml
|
| 1005 | 1005 | -- Minimal complete definition = the only shown method
|
| 1006 | - Var (L _ n) : _
|
|
| 1006 | + Var _ (L _ n) : _
|
|
| 1007 | 1007 | | [getName n]
|
| 1008 | 1008 | == [getName n' | ClassOpSig _ _ ns _ <- sigs, L _ n' <- ns] ->
|
| 1009 | 1009 | noHtml
|
| 1010 | 1010 | -- Minimal complete definition = nothing
|
| 1011 | - And [] : _ -> subMinimal $ toHtml ("Nothing" :: LText)
|
|
| 1011 | + And _ [] : _ -> subMinimal $ toHtml ("Nothing" :: LText)
|
|
| 1012 | 1012 | m : _ -> subMinimal $ ppMinimal False m
|
| 1013 | 1013 | _ -> noHtml
|
| 1014 | 1014 | |
| 1015 | - ppMinimal _ (Var (L _ n)) = ppDocName qual Prefix True n
|
|
| 1016 | - ppMinimal _ (And fs) = foldr1 (\a b -> a +++ (", " :: LText) +++ b) $ map (ppMinimal True . unLoc) fs
|
|
| 1017 | - ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a +++ (" | " :: LText) +++ b) $ map (ppMinimal False . unLoc) fs
|
|
| 1015 | + ppMinimal _ (Var _ (L _ n)) = ppDocName qual Prefix True n
|
|
| 1016 | + ppMinimal _ (And _ fs) = foldr1 (\a b -> a +++ (", " :: LText) +++ b) $ map (ppMinimal True . unLoc) fs
|
|
| 1017 | + ppMinimal p (Or _ fs) = wrap $ foldr1 (\a b -> a +++ (" | " :: LText) +++ b) $ map (ppMinimal False . unLoc) fs
|
|
| 1018 | 1018 | where
|
| 1019 | 1019 | wrap | p = parens | otherwise = id
|
| 1020 | - ppMinimal p (Parens x) = ppMinimal p (unLoc x)
|
|
| 1020 | + ppMinimal p (Parens _ x) = ppMinimal p (unLoc x)
|
|
| 1021 | 1021 | |
| 1022 | 1022 | -- Instances
|
| 1023 | 1023 | instancesBit =
|
| ... | ... | @@ -858,10 +858,10 @@ bfTraverse :: Applicative f |
| 858 | 858 | -> f (BooleanFormula DocNameI)
|
| 859 | 859 | bfTraverse f = go
|
| 860 | 860 | where
|
| 861 | - go (Var a ) = Var <$> f a
|
|
| 862 | - go (And bfs) = And <$> traverse @[] (traverse go) bfs
|
|
| 863 | - go (Or bfs) = Or <$> traverse @[] (traverse go) bfs
|
|
| 864 | - go (Parens bf ) = Parens <$> traverse go bf
|
|
| 861 | + go (Var x a ) = Var x <$> f a
|
|
| 862 | + go (And x bfs) = And x <$> traverse @[] (traverse go) bfs
|
|
| 863 | + go (Or x bfs) = Or x <$> traverse @[] (traverse go) bfs
|
|
| 864 | + go (Parens x bf ) = Parens x <$> traverse go bf
|
|
| 865 | 865 | |
| 866 | 866 | renameForD :: ForeignDecl GhcRn -> RnM (ForeignDecl DocNameI)
|
| 867 | 867 | renameForD (ForeignImport _ modifiers lname ltype x) = do
|
| ... | ... | @@ -1038,6 +1038,12 @@ type instance XCTyFamInstDecl DocNameI = NoExtField |
| 1038 | 1038 | type instance XHsContext DocNameI = NoExtField
|
| 1039 | 1039 | type instance XXHsContextDetails DocNameI = DataConCantHappen
|
| 1040 | 1040 | |
| 1041 | +type instance XBFVar DocNameI = NoExtField
|
|
| 1042 | +type instance XBFAnd DocNameI = NoExtField
|
|
| 1043 | +type instance XBFOr DocNameI = NoExtField
|
|
| 1044 | +type instance XBFParens DocNameI = NoExtField
|
|
| 1045 | +type instance XXBooleanFormula DocNameI = DataConCantHappen
|
|
| 1046 | + |
|
| 1041 | 1047 | -----------------------------------------------------------------------------
|
| 1042 | 1048 | |
| 1043 | 1049 | -- * NFData instances for GHC types
|