Skip to content

Commit a960116

Browse files
committed
update to agda 2.8.0
1 parent 57fd6c0 commit a960116

File tree

4 files changed

+27
-38
lines changed

4 files changed

+27
-38
lines changed

cabal.project

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
packages: agda2lambox.cabal
2-
3-
source-repository-package
4-
type: git
5-
location: https://github.com/agda/agda
6-
tag: 5c29109f8212ef61b0091d62ef9c8bfdfa16cf36
7-
82
constraints: Agda +debug

flake.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs";
66
flake-utils.url = "github:numtide/flake-utils";
7-
agda = {
8-
url = "github:agda/agda";
9-
flake = false;
10-
};
117
};
128

139
outputs =
@@ -35,7 +31,6 @@
3531
haskellPackages = prev.haskellPackages.extend (
3632
hfinal: hprev: {
3733
sexpresso = hLib.doJailbreak (hLib.markUnbroken hprev.sexpresso);
38-
Agda = hLib.dontCheck (hLib.dontHaddock (hfinal.callCabal2nix "Agda" inputs.agda { }));
3934
agda2lambox = hLib.doJailbreak (hfinal.callCabal2nix "agda2lambox" ./. { });
4035
}
4136
);

src/Agda/Utils/Treeless.hs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import Agda.Compiler.Treeless.AsPatterns
4848
import Agda.Compiler.Treeless.Builtin
4949
import Agda.Compiler.Treeless.Erase
5050
import Agda.Compiler.Treeless.Identity
51+
import Agda.Compiler.Treeless.Simplify
5152
import Agda.Compiler.Treeless.Uncase
5253
import Agda.Compiler.Treeless.Unused
5354
import Agda.Compiler.Treeless.NormalizeNames
@@ -85,7 +86,7 @@ getCompiledClauses q = do
8586
reportSDoc "treeless.convert" 70 $
8687
caseMaybe mst "-- not using split tree" $ \st ->
8788
"-- using split tree" $$ pretty st
88-
CC.compileClauses' translate cs mst
89+
CC.compileClauses' q translate cs mst
8990

9091
-- ** Types of pipelines; different backends might use their own custom pipeline.
9192
type BuildPipeline = Int -> QName -> Pipeline
@@ -109,7 +110,7 @@ data CCSubst = EraseUnused | IgnoreUnused deriving Eq
109110
data CCEnv = CCEnv
110111
{ ccCxt :: CCContext
111112
-- ^ Maps case tree de-bruijn indices to TTerm de-bruijn indices.
112-
, ccCatchAll :: Maybe Int
113+
, ccCatchall :: Maybe Int
113114
-- ^ TTerm de-bruijn index of the current catch all.
114115
-- If an inner case has no catch-all clause, we use the one from its parent.
115116
, ccEvaluation :: EvaluationStrategy
@@ -124,7 +125,7 @@ type CCConfig = (EvaluationStrategy, CCSubst)
124125
initCCEnv :: CCConfig -> CCEnv
125126
initCCEnv (eval, su) = CCEnv
126127
{ ccCxt = []
127-
, ccCatchAll = Nothing
128+
, ccCatchall = Nothing
128129
, ccEvaluation = eval
129130
, ccSubstUnused = su
130131
}
@@ -286,14 +287,14 @@ casetree cc = do
286287
CC.Case _ (CC.Branches True _ _ _ Just{} _ _) -> __IMPOSSIBLE__
287288
CC.Case (Arg _ n) (CC.Branches True conBrs _ _ Nothing _ _) -> lambdasUpTo n $ do
288289
mkRecord =<< traverse casetree (CC.content <$> conBrs)
289-
CC.Case (Arg i n) (CC.Branches False conBrs etaBr litBrs catchAll _ lazy) -> lambdasUpTo (n + 1) $ do
290+
CC.Case (Arg i n) (CC.Branches False conBrs etaBr litBrs catchall _ lazy) -> lambdasUpTo (n + 1) $ do
290291
-- re #3733 TODO: revise when compiling --cubical
291292
conBrs <- fmap Map.fromList $ filterM (isConstructor . fst) (Map.toList conBrs)
292293
-- We can treat eta-matches as regular matches here.
293294
let conBrs' = caseMaybe etaBr conBrs $ \ (c, br) -> Map.insertWith (\ new old -> old) (conName c) br conBrs
294295
if Map.null conBrs' && Map.null litBrs then do
295296
-- there are no branches, just return default
296-
updateCatchAll catchAll fromCatchAll
297+
updateCatchall catchall fromCatchall
297298
else do
298299
-- Get the type of the scrutinee.
299300
caseTy <-
@@ -311,9 +312,9 @@ casetree cc = do
311312
([], LitQName _ : _) -> return C.CTQName
312313
_ -> __IMPOSSIBLE__
313314

314-
updateCatchAll catchAll $ do
315+
updateCatchall catchall $ do
315316
x <- asks (lookupLevel n . ccCxt)
316-
def <- fromCatchAll
317+
def <- fromCatchall
317318
let caseInfo = C.CaseInfo
318319
{ caseType = caseTy
319320
, caseLazy = lazy
@@ -327,8 +328,8 @@ casetree cc = do
327328
where
328329
-- normally, Agda should make sure that a pattern match is total,
329330
-- so we set the default to unreachable if no default has been provided.
330-
fromCatchAll :: CC C.TTerm
331-
fromCatchAll = asks (maybe C.tUnreachable C.TVar . ccCatchAll)
331+
fromCatchall :: CC C.TTerm
332+
fromCatchall = asks (maybe C.tUnreachable C.TVar . ccCatchall)
332333

333334
commonArity :: CC.CompiledClauses -> Int
334335
commonArity cc =
@@ -349,21 +350,21 @@ commonArity cc =
349350

350351
wArities cxt (WithArity k c) = map (\ x -> x - k + 1) $ arities (cxt - 1 + k) c
351352

352-
updateCatchAll :: Maybe CC.CompiledClauses -> (CC C.TTerm -> CC C.TTerm)
353-
updateCatchAll Nothing cont = cont
354-
updateCatchAll (Just cc) cont = do
353+
updateCatchall :: Maybe CC.CompiledClauses -> (CC C.TTerm -> CC C.TTerm)
354+
updateCatchall Nothing cont = cont
355+
updateCatchall (Just cc) cont = do
355356
def <- casetree cc
356357
cxt <- asks ccCxt
357358
reportS "treeless.convert.lambdas" 40 $
358-
[ "-- updateCatchAll:"
359+
[ "-- updateCatchall:"
359360
, "-- cxt =" <+> prettyPure cxt
360361
, "-- def =" <+> prettyPure def
361362
]
362-
local (\ e -> e { ccCatchAll = Just 0, ccCxt = shift 1 cxt }) $ do
363+
local (\ e -> e { ccCatchall = Just 0, ccCxt = shift 1 cxt }) $ do
363364
C.mkLet def <$> cont
364365

365366
-- | Shrinks or grows the context to the given size.
366-
-- Does not update the catchAll expression, the catchAll expression
367+
-- Does not update the catchall expression, the catchall expression
367368
-- MUST NOT be used inside `cont`.
368369
withContextSize :: Int -> CC C.TTerm -> CC C.TTerm
369370
withContextSize n cont = do
@@ -430,8 +431,8 @@ withContextSize n cont = do
430431
cont <&> (`C.mkTApp` map C.TVar (downFrom diff'))
431432

432433
-- | Prepend the given positive number of lambdas.
433-
-- Does not update the catchAll expression,
434-
-- the catchAll expression must be updated separately (or not be used).
434+
-- Does not update the catchall expression,
435+
-- the catchall expression must be updated separately (or not be used).
435436
createLambdas :: Int -> CC C.TTerm -> CC C.TTerm
436437
createLambdas diff cont = do
437438
unless (diff >= 1) __IMPOSSIBLE__
@@ -446,30 +447,30 @@ createLambdas diff cont = do
446447
cont <&> \ t -> List.iterate C.TLam t !! diff
447448

448449
-- | Adds lambdas until the context has at least the given size.
449-
-- Updates the catchAll expression to take the additional lambdas into account.
450+
-- Updates the catchall expression to take the additional lambdas into account.
450451
lambdasUpTo :: Int -> CC C.TTerm -> CC C.TTerm
451452
lambdasUpTo n cont = do
452453
diff <- asks (((n -) . length) . ccCxt)
453454

454455
if diff <= 0 then cont -- no new lambdas needed
455456
else do
456457
createLambdas diff $ do
457-
asks ccCatchAll >>= \case
458-
Just catchAll -> do
458+
asks ccCatchall >>= \case
459+
Just catchall -> do
459460
cxt <- asks ccCxt
460461
reportS "treeless.convert.lambdas" 40 $
461462
[ "lambdasUpTo: n =" <+> (text . show) n
462463
, " diff =" <+> (text . show) n
463-
, " catchAll =" <+> prettyPure catchAll
464+
, " catchall =" <+> prettyPure catchall
464465
, " ccCxt =" <+> prettyPure cxt
465466
]
466467
-- the catch all doesn't know about the additional lambdas, so just directly
467468
-- apply it again to the newly introduced lambda arguments.
468469
-- we also bind the catch all to a let, to avoid code duplication
469-
local (\e -> e { ccCatchAll = Just 0
470+
local (\e -> e { ccCatchall = Just 0
470471
, ccCxt = shift 1 cxt }) $ do
471-
let catchAllArgs = map C.TVar $ downFrom diff
472-
C.mkLet (C.mkTApp (C.TVar $ catchAll + diff) catchAllArgs)
472+
let catchallArgs = map C.TVar $ downFrom diff
473+
C.mkLet (C.mkTApp (C.TVar $ catchall + diff) catchallArgs)
473474
<$> cont
474475
Nothing -> cont
475476

@@ -499,7 +500,7 @@ replaceVar x n cont = do
499500
(ys, _:zs) = splitAt i cxt
500501
-- compute the de-bruijn indexes of the newly inserted variables
501502
ixs = [0..(n - 1)]
502-
local (\e -> e { ccCxt = upd (ccCxt e) , ccCatchAll = (+ n) <$> ccCatchAll e }) $
503+
local (\e -> e { ccCxt = upd (ccCxt e) , ccCatchall = (+ n) <$> ccCatchall e }) $
503504
cont
504505

505506

@@ -651,4 +652,3 @@ substArgs = traverse substArg
651652
substArg :: Arg I.Term -> CC C.TTerm
652653
substArg x | usableModality x = substTerm (unArg x)
653654
| otherwise = return C.TErased
654-

src/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Data.Maybe ( fromMaybe )
1313
import Data.Version ( showVersion )
1414
import Data.Text ( pack )
1515
import GHC.Generics ( Generic )
16-
import System.Console.GetOpt ( OptDescr(Option), ArgDescr(..) )
16+
import Agda.Utils.GetOpt ( OptDescr(Option), ArgDescr(..) )
1717
import System.Directory ( createDirectoryIfMissing )
1818
import System.FilePath ( (</>), (-<.>) )
1919
import Data.Text.Lazy.IO qualified as LText

0 commit comments

Comments
 (0)