Skip to content
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

[ refactor ] ScopedSnocList: WIP #3368

Draft
wants to merge 95 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
e24d587
LOG: Structural logging
GulinSS Dec 17, 2024
24391b9
LOG: Structural logging depth applied
GulinSS Dec 17, 2024
55f006c
LOG: Reduce log output for log output
GulinSS Jan 16, 2025
d98773c
ScopedSnocList: WIP
GulinSS Aug 5, 2024
e389b4c
ScopedSnocList: WIP replaced `SLNil` with `[<]`.
GulinSS Aug 15, 2024
27370aa
ScopedSnocList: special operators for snoc simulation
GulinSS Aug 15, 2024
69aa566
ScopedSnocList: WIP removed ScopedList and replace it on SnocList at …
GulinSS Sep 20, 2024
52a326e
ScopedSnocList: WIP: `b +%+ c ... => c ++ b ...`
GulinSS Sep 20, 2024
e8282bb
ScopedSnocList: WIP: `a ((b +%+ c) +%+ d) => a (c ++ (d <>< b))`
GulinSS Sep 20, 2024
46fc266
ScopedSnocList: WIP: `a (b +%+ c :%: d) => a (d :< c <>< b) | a (d :<…
GulinSS Sep 20, 2024
08fd53b
ScopedSnocList: WIP: `a (b :%: c +%+ d) => a (d <>< c :< b) | a (d ++…
GulinSS Sep 20, 2024
3a03e86
ScopedSnocList: WIP: `a (b +%+ (c +%+ d :%: e)) => a ((e :< d <>< c) …
GulinSS Sep 20, 2024
276515c
ScopedSnocList: WIP: `a (b +%+ (c :%: d +%+ e)) => a ((e <>< d :< c) …
GulinSS Sep 20, 2024
8ff8b59
ScopedSnocList: WIP: `a (b +%+ c :%: (d +%+ e)) => a ((e <>< d :< c) …
GulinSS Sep 20, 2024
aacebf0
ScopedSnocList: WIP: `a (b +%+ c :%: d :%: e) => a (e :< d :< c ++ b)`
GulinSS Sep 20, 2024
a9ed443
ScopedSnocList: WIP: `a (b +%+ (c +%+ (d :%: e))) => a ((e :< d <>< c…
GulinSS Sep 20, 2024
84a20d7
ScopedSnocList: WIP: Move `Thin` into `Scoped`
GulinSS Sep 20, 2024
757fad7
ScopedSnocList: WIP: `(a +%+ fromList b => a <>< b) + (toList a ++ b …
GulinSS Sep 20, 2024
a0dd16d
ScopedSnocList: WIP: `a :%: b ... => b :< a ...`
GulinSS Sep 20, 2024
186ce16
ScopedSnocList: WIP: `($AA :%: ($AA | [<])) => [<$AA, ...]`
GulinSS Sep 22, 2024
9ae5703
ScopedSnocList: WIP: move CompatibleVars on SnocList
GulinSS Sep 21, 2024
7eeb558
ScopedSnocList: WIP: add `zero` and `suc` ops to `Data.SnocList.SizeOf`
GulinSS Sep 21, 2024
f4337b9
ScopedSnocList: WIP: update SnocList imports for `Core.Name.Scoped`
GulinSS Sep 21, 2024
ae2579f
ScopedSnocList: WIP: add `CompatibleVars` to `Var`
GulinSS Sep 21, 2024
ed57898
ScopedSnocList: WIP: `(a :%: b ** c) => (b :< a ** c)`
GulinSS Sep 22, 2024
d6ee16a
ScopedSnocList: WIP: `$AA <>> $BB :%: $CC => $AA <>> $CC :< $BB`
GulinSS Sep 23, 2024
3d379e6
ScopedSnocList: WIP: Remove logical dupe `Reify (SnocList a)`
GulinSS Sep 23, 2024
2ad6372
ScopedSnocList: WIP: `a <>> b :%: (c +%+ d) => a <>> (d ++ c) :< b`
GulinSS Sep 23, 2024
9c56623
ScopedSnocList: WIP: `(a +%+ b) +%+ (c :%: d +%+ e) => (e ++ d :< c) …
GulinSS Sep 23, 2024
81bbb88
ScopedSnocList: WIP: `getRewriteTerms` : remove `reverse` and use `:<…
GulinSS Sep 23, 2024
cf3ba8a
ScopedSnocList: WIP: `$AA <>> $BB +%+ $CC => $AA <>> $CC ++ $BB`
GulinSS Sep 23, 2024
418761f
ScopedSnocList: WIP: `$AA +%+ ($BB <>> ($CC +%+ $DD)) => ($BB <>> ($D…
GulinSS Sep 23, 2024
a8b1a23
ScopedSnocList: WIP: `a (b +%+ c) => a (c ++ b)` but actually a speci…
GulinSS Sep 23, 2024
1070114
ScopedSnocList: WIP: add `import Libraries.Data.SnocList.SizeOf` and …
GulinSS Sep 23, 2024
c220a44
ScopedSnocList: WIP: aligned with `Yaffle` the following: `GenWeakena…
GulinSS Sep 27, 2024
4a8b120
ScopedSnocList: WIP: aligned with `Yaffle` the following: `GenWeakena…
GulinSS Oct 1, 2024
833231b
ScopedSnocList: WIP: aligned with `Yaffle` the following: `Context`.
GulinSS Oct 1, 2024
2be24be
ScopedSnocList: WIP: rewrites to Snock `ANF` and `LambdaLift`
GulinSS Oct 1, 2024
f4599d2
ScopedSnocList: WIP: casts to SnocList from List at `Eval`
GulinSS Oct 1, 2024
c771617
ScopedSnocList: WIP: replace `<><` with `++` at `CaseOpts`
GulinSS Oct 1, 2024
39f722e
ScopedSnocList: WIP: correct list functions with snoc ones for `Compi…
GulinSS Oct 1, 2024
d1b839a
ScopedSnocList: WIP: correct list functions with snoc ones for `Inlin…
GulinSS Oct 2, 2024
580d5d7
ScopedSnocList: WIP: trivial constructor substitutions
GulinSS Oct 3, 2024
bb7ddda
ScopedSnocList: WIP: remove **unused** code from `Var`.
GulinSS Oct 4, 2024
1e4a5dd
ScopedSnocList: WIP: remove **unused** (`unBinds`) code from `Traver…
GulinSS Oct 4, 2024
5174a39
ScopedSnocList: WIP: use `List` at `Meta` and `NMeta`, risky changes …
GulinSS Oct 7, 2024
b1cae69
ScopedSnocList: WIP: rewrites
GulinSS Oct 8, 2024
2b2b744
ScopedSnocList: WIP: **rollback** replace Stack on StackSnoc for `Nor…
GulinSS Oct 10, 2024
b156e75
ScopedSnocList: WIP: use List stack at `TTImp`, separate `applyStackW…
GulinSS Oct 27, 2024
8e7ccab
ScopedSnocList: WIP: use Snoc for `LocalEnv`
GulinSS Oct 27, 2024
156e2f7
ScopedSnocList: WIP: introduce SnocList for `NMeta`
GulinSS Oct 27, 2024
dd9a506
ScopedSnocList: WIP: fixed `findLinear`
GulinSS Oct 11, 2024
3ca398f
ScopedSnocList: WIP: fixed `mkPatClause`, added `getArgTys`
GulinSS Oct 17, 2024
021508d
ScopedSnocList: WIP: reversed `DelayCase`
GulinSS Oct 18, 2024
3027901
ScopedSnocList: WIP: fixes for `addDelayG`
GulinSS Oct 22, 2024
3049a7a
ScopedSnocList: WIP: use `nextNames` from `Yaffle`
GulinSS Oct 23, 2024
665a17b
ScopedSnocList: WIP: fixes `unify`
GulinSS Oct 24, 2024
0292148
ScopedSnocList: WIP: use SnocList at `Core.Unify`
GulinSS Oct 29, 2024
425f0e9
ScopedSnocList: WIP: logs improvements
GulinSS Oct 29, 2024
3a0b72b
ScopedSnocList: Fix rebase with full history unhidding
GulinSS Aug 5, 2024
75c5131
ScopedSnocList: add `Show` to `SubstCEnv`
GulinSS Nov 29, 2024
293f4de
ScopedSnocList: Trivial logging
GulinSS Oct 31, 2024
f74e715
ScopedSnocList: Trivial reversal logging
GulinSS Nov 27, 2024
cec6bdd
ScopedSnocList: Disable too noisy logs
GulinSS Dec 13, 2024
f694c39
ScopedSnocList: More logging (+ reverse)
GulinSS Jan 16, 2025
5681e66
ScopedSnocList: Restore logging sequence
GulinSS Oct 31, 2024
1993adb
ScopedSnocList: Reverse tooling for LocalEnv
GulinSS Nov 7, 2024
920240a
ScopedSnocList: Reverse tooling for Var
GulinSS Nov 7, 2024
567044e
ScopedSnocList: Reverse tooling `Inline` and `CompileExpr`
GulinSS Jan 16, 2025
30c4d7b
ScopedSnocList: Use `implicitsAs` with reversed list of variables
GulinSS Nov 7, 2024
b893398
ScopedSnocList: Fix reversed order of arguments in `getArgTys` NF sub…
GulinSS Nov 8, 2024
edf6bef
ScopedSnocList: Use `substName` from Allais (do not know why)
GulinSS Nov 16, 2024
6de90d6
ScopedSnocList: Use `weakenNs` instead of `addLater` from Allais (do …
GulinSS Nov 16, 2024
49d32d6
ScopedSnocList: Yaffle uses `normalizeLHS` instead of `normalizeHoles…
GulinSS Nov 16, 2024
d7abc65
ScopedSnocList: Correct order of `var`s for `patCompile` and `mkPatCl…
GulinSS Nov 19, 2024
fc4a1e6
ScopedSnocList: Make `XX`, `YY` at `{arg:XX}` and `{e:YY}` follow ori…
GulinSS Nov 22, 2024
4757a0b
ScopedSnocList: Useful comments
GulinSS Dec 5, 2024
8854614
ScopedSnocList: Ported mkSub from Yaffle
GulinSS Dec 5, 2024
b60721b
ScopedSnocList: WIP: Use `List` of `args` at `ConCase` and its childr…
GulinSS Dec 3, 2024
27ee3e3
ScopedSnocList: Use `List` of `args` at `ConCase` and its children (i…
GulinSS Dec 3, 2024
8b700f8
ScopedSnocList: Correct order of `NTCon` for `findPos` and `checkConc…
GulinSS Dec 10, 2024
054d35f
ScopedSnocList: Fix constant fold
GulinSS Dec 20, 2024
158ac7d
ScopedSnocList: Correct behavior for `getPMDef`
GulinSS Jan 17, 2025
7ab5a70
ScopedSnocList: Fix hanging on interface implementation inlining
GulinSS Jan 24, 2025
d736f32
ScopedSnocList: Correct `unifyInvertible` reverse positions
GulinSS Jan 24, 2025
c6612cb
ScopedSnocList: `convGen` expects to deal with reverse processing of …
GulinSS Jan 24, 2025
753b645
ScopedSnocList: Fix `concrete`
GulinSS Jan 24, 2025
d0790d6
ScopedSnocList: Fix correct order of `NTCon`/`NDCon` for reify and elab
GulinSS Jan 29, 2025
48945ab
ScopedSnocList: Fix `dropPos` at `eraseApps`
GulinSS Jan 30, 2025
1657b6e
ScopedSnocList: Trivial logging
GulinSS Jan 30, 2025
25ad379
ScopedSnocList: Useful comments
GulinSS Jan 30, 2025
7fc2f3a
ScopedSnocList: Trivial reversal logging
GulinSS Jan 30, 2025
b2542e3
ScopedSnocList: Fix CI
GulinSS Jan 30, 2025
21991b1
ScopedSnocList: remove useless logs
GulinSS Feb 7, 2025
0cc8688
ScopedSnocList: Preventing too deep evaluation at `getArgTys`
GulinSS Feb 7, 2025
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
10 changes: 10 additions & 0 deletions libs/base/Data/SnocList.idr
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,13 @@ tailRecAppendIsAppend : (sx, sy : SnocList a) -> tailRecAppend sx sy = sx ++ sy
tailRecAppendIsAppend sx Lin = Refl
tailRecAppendIsAppend sx (sy :< y) =
trans (snocTailRecAppend y sx sy) (cong (:< y) $ tailRecAppendIsAppend sx sy)

||| `reverseOnto` reverses the snoc list and prepends it to the "onto" argument
export
revOnto : (xs, vs : SnocList a) -> reverseOnto xs vs = xs ++ reverse vs
revOnto _ [<] = Refl
revOnto xs (vs :< v) =
do rewrite revOnto (xs :< v) vs
rewrite sym $ appendAssociative xs [<v] (reverse vs)
rewrite revOnto [<v] vs
Refl
6 changes: 3 additions & 3 deletions libs/base/Data/SnocList/HasLength.idr
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ map f Z = Z
map f (S hl) = S (map f hl)

export
sucL : HasLength n sx -> HasLength (S n) ([<x] ++ sx)
sucL Z = S Z
sucL (S n) = S (sucL n)
sucR : HasLength n sx -> HasLength (S n) ([<x] ++ sx)
sucR Z = S Z
sucR (S n) = S (sucR n)

export
hlAppend : HasLength m sx -> HasLength n sy -> HasLength (n + m) (sx ++ sy)
Expand Down
58 changes: 27 additions & 31 deletions src/Compiler/ANF.idr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import Core.Core
import Core.TT

import Data.List
import Data.SnocList
import Data.Vect
import Libraries.Data.SortedSet
import Libraries.Data.SnocList.Extra

%default covering

Expand Down Expand Up @@ -136,9 +138,9 @@ Show ANFDef where
show args ++ " -> " ++ show ret
show (MkAError exp) = "Error: " ++ show exp

data AVars : List Name -> Type where
Nil : AVars []
(::) : Int -> AVars xs -> AVars (x :: xs)
data AVars : SnocList Name -> Type where
Lin : AVars [<]
(:<) : AVars xs -> Int -> AVars (xs :< x)

data Next : Type where

Expand All @@ -150,8 +152,8 @@ nextVar
pure i

lookup : {idx : _} -> (0 p : IsVar x idx vs) -> AVars vs -> Int
lookup First (x :: xs) = x
lookup (Later p) (x :: xs) = lookup p xs
lookup First (xs :< x) = x
lookup (Later p) (xs :< x) = lookup p xs

bindArgs : {auto v : Ref Next Int} ->
List ANF -> Core (List (AVar, Maybe ANF))
Expand Down Expand Up @@ -187,14 +189,23 @@ mlet fc val sc
= do i <- nextVar
pure $ ALet fc i val (sc (ALocal i))

bindAsFresh :
{auto v : Ref Next Int} ->
(args : List Name) -> AVars vars' ->
Core (List Int, AVars (vars' <>< args))
bindAsFresh [] vs = pure ([], vs)
bindAsFresh (n :: ns) vs
= do i <- nextVar
mapFst (i ::) <$> bindAsFresh ns (vs :< i)

mutual
anfArgs : {vars : _} ->
{auto v : Ref Next Int} ->
FC -> AVars vars ->
List (Lifted vars) -> (List AVar -> ANF) -> Core ANF
anfArgs fc vs args f
= do args' <- traverse (anf vs) args
letBind fc args' f
letBind fc (toList args') f

anf : {vars : _} ->
{auto v : Ref Next Int} ->
Expand All @@ -211,7 +222,7 @@ mutual
_ => ACrash fc "Can't happen (AApp)"
anf vs (LLet fc x val sc)
= do i <- nextVar
let vs' = i :: vs
let vs' = vs :< i
pure $ ALet fc i !(anf vs val) !(anf vs' sc)
anf vs (LCon fc n ci t args)
= anfArgs fc vs args (ACon fc n ci t)
Expand Down Expand Up @@ -241,16 +252,8 @@ mutual
{auto v : Ref Next Int} ->
AVars vars -> LiftedConAlt vars -> Core AConAlt
anfConAlt vs (MkLConAlt n ci t args sc)
= do (is, vs') <- bindArgs args vs
= do (is, vs') <- bindAsFresh args vs
pure $ MkAConAlt n ci t is !(anf vs' sc)
where
bindArgs : (args : List Name) -> AVars vars' ->
Core (List Int, AVars (args ++ vars'))
bindArgs [] vs = pure ([], vs)
bindArgs (n :: ns) vs
= do i <- nextVar
(is, vs') <- bindArgs ns vs
pure (i :: is, i :: vs')

anfConstAlt : {vars : _} ->
{auto v : Ref Next Int} ->
Expand All @@ -262,25 +265,18 @@ export
toANF : LiftedDef -> Core ANFDef
toANF (MkLFun args scope sc)
= do v <- newRef Next (the Int 0)
(iargs, vsNil) <- bindArgs args []
let vs : AVars args = rewrite sym (appendNilRightNeutral args) in
vsNil
(iargs', vs) <- bindArgs scope vs
pure $ MkAFun (iargs ++ reverse iargs') !(anf vs sc)
where
bindArgs : {auto v : Ref Next Int} ->
(args : List Name) -> AVars vars' ->
Core (List Int, AVars (args ++ vars'))
bindArgs [] vs = pure ([], vs)
bindArgs (n :: ns) vs
= do i <- nextVar
(is, vs') <- bindArgs ns vs
pure (i :: is, i :: vs')
(iargs, vsNil) <- bindAsFresh (cast args) [<]
let vs : AVars args
:= rewrite sym $ appendLinLeftNeutral args in
rewrite snocAppendAsFish [<] args in vsNil
(iargs', vs) <- bindAsFresh (cast scope) vs
sc' <- anf (rewrite snocAppendAsFish args scope in vs) sc
pure $ MkAFun (iargs ++ reverse iargs') sc'
toANF (MkLCon t a ns) = pure $ MkACon t a ns
toANF (MkLForeign ccs fargs t) = pure $ MkAForeign ccs fargs t
toANF (MkLError err)
= do v <- newRef Next (the Int 0)
pure $ MkAError !(anf [] err)
pure $ MkAError !(anf [<] err)

export
freeVariables : ANF -> SortedSet AVar
Expand Down
68 changes: 37 additions & 31 deletions src/Compiler/CaseOpts.idr
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import Core.FC
import Core.TT

import Data.List
import Data.SnocList
import Data.Vect

import Libraries.Data.List.SizeOf
import Libraries.Data.SnocList.SizeOf
import Libraries.Data.SnocList.Extra

%default covering

{-
Expand All @@ -32,38 +37,39 @@ case t of

shiftUnder : {args : _} ->
{idx : _} ->
(0 p : IsVar n idx (x :: args ++ vars)) ->
NVar n (args ++ x :: vars)
(0 p : IsVar n idx (vars ++ args :< x)) ->
NVar n (vars :< x ++ args)
shiftUnder First = weakenNVar (mkSizeOf args) (MkNVar First)
shiftUnder (Later p) = insertNVar (mkSizeOf args) (MkNVar p)

shiftVar : {outer, args : Scope} ->
NVar n (outer ++ (x :: args ++ vars)) ->
NVar n (outer ++ (args ++ x :: vars))
shiftVar : {outer : Scope} -> {args : List Name} ->
NVar n ((vars <>< args :< x) ++ outer) ->
NVar n ((vars :< x <>< args) ++ outer)
shiftVar nvar
= let out = mkSizeOf outer in
-- TODO: G.Allois version has Left/Right swap
case locateNVar out nvar of
Left nvar => embed nvar
Right (MkNVar p) => weakenNs out (shiftUnder p)
Right (MkNVar p) => weakenNs out (shiftUndersN (mkSizeOf _) p)

mutual
renameVar : IsVar x i ((vars :< old <>< args) ++ local) ->
IsVar x i ((vars :< new <>< args) ++ local)
renameVar = believe_me -- it's the same index, so just the identity at run time

shiftBinder : {outer, args : _} ->
(new : Name) ->
CExp (outer ++ old :: (args ++ vars)) ->
CExp (outer ++ (args ++ new :: vars))
CExp (((vars <>< args) :< old) ++ outer) ->
CExp ((vars :< new <>< args) ++ outer)
shiftBinder new (CLocal fc p)
= case shiftVar (MkNVar p) of
MkNVar p' => CLocal fc (renameVar p')
where
renameVar : IsVar x i (outer ++ (args ++ (old :: rest))) ->
IsVar x i (outer ++ (args ++ (new :: rest)))
renameVar = believe_me -- it's the same index, so just the identity at run time
shiftBinder new (CRef fc n) = CRef fc n
shiftBinder {outer} new (CLam fc n sc)
= CLam fc n $ shiftBinder {outer = n :: outer} new sc
= CLam fc n $ shiftBinder {outer = outer :< n} new sc
shiftBinder new (CLet fc n inlineOK val sc)
= CLet fc n inlineOK (shiftBinder new val)
$ shiftBinder {outer = n :: outer} new sc
$ shiftBinder {outer = outer :< n} new sc
shiftBinder new (CApp fc f args)
= CApp fc (shiftBinder new f) $ map (shiftBinder new) args
shiftBinder new (CCon fc ci c tag args)
Expand All @@ -85,36 +91,36 @@ mutual
shiftBinder new (CErased fc) = CErased fc
shiftBinder new (CCrash fc msg) = CCrash fc msg

shiftBinderConAlt : {outer, args : _} ->
shiftBinderConAlt : {outer : _} -> {args : _} ->
(new : Name) ->
CConAlt (outer ++ (x :: args ++ vars)) ->
CConAlt (outer ++ (args ++ new :: vars))
CConAlt (((vars <>< args) :< old) ++ outer) ->
CConAlt ((vars :< new <>< args) ++ outer)
shiftBinderConAlt new (MkConAlt n ci t args' sc)
= let sc' : CExp ((args' ++ outer) ++ (x :: args ++ vars))
= rewrite sym (appendAssociative args' outer (x :: args ++ vars)) in sc in
= let sc' : CExp (((vars <>< args) :< old) ++ (outer <>< args'))
= rewrite sym $ snocAppendFishAssociative (vars <>< args :< old) outer args' in sc in
MkConAlt n ci t args' $
rewrite (appendAssociative args' outer (args ++ new :: vars))
in shiftBinder new {outer = args' ++ outer} sc'
rewrite snocAppendFishAssociative (vars :< new <>< args) outer args'
in shiftBinder new {outer = outer <>< args'} sc'

shiftBinderConstAlt : {outer, args : _} ->
(new : Name) ->
CConstAlt (outer ++ (x :: args ++ vars)) ->
CConstAlt (outer ++ (args ++ new :: vars))
CConstAlt (((vars <>< args) :< old) ++ outer) ->
CConstAlt ((vars :< new <>< args) ++ outer)
shiftBinderConstAlt new (MkConstAlt c sc) = MkConstAlt c $ shiftBinder new sc

-- If there's a lambda inside a case, move the variable so that it's bound
-- outside the case block so that we can bind it just once outside the block
liftOutLambda : {args : _} ->
(new : Name) ->
CExp (old :: args ++ vars) ->
CExp (args ++ new :: vars)
liftOutLambda = shiftBinder {outer = []}
CExp (vars <>< args :< old) ->
CExp (vars :< new <>< args)
liftOutLambda = shiftBinder {outer = [<]}

-- If all the alternatives start with a lambda, we can have a single lambda
-- binding outside
tryLiftOut : (new : Name) ->
List (CConAlt vars) ->
Maybe (List (CConAlt (new :: vars)))
Maybe (List (CConAlt (vars :< new)))
tryLiftOut new [] = Just []
tryLiftOut new (MkConAlt n ci t args (CLam fc x sc) :: as)
= do as' <- tryLiftOut new as
Expand All @@ -124,7 +130,7 @@ tryLiftOut _ _ = Nothing

tryLiftOutConst : (new : Name) ->
List (CConstAlt vars) ->
Maybe (List (CConstAlt (new :: vars)))
Maybe (List (CConstAlt (vars :< new)))
tryLiftOutConst new [] = Just []
tryLiftOutConst new (MkConstAlt c (CLam fc x sc) :: as)
= do as' <- tryLiftOutConst new as
Expand All @@ -134,7 +140,7 @@ tryLiftOutConst _ _ = Nothing

tryLiftDef : (new : Name) ->
Maybe (CExp vars) ->
Maybe (Maybe (CExp (new :: vars)))
Maybe (Maybe (CExp (vars :< new)))
tryLiftDef new Nothing = Just Nothing
tryLiftDef new (Just (CLam fc x sc))
= let sc' = liftOutLambda {args = []} new sc in
Expand Down Expand Up @@ -313,8 +319,8 @@ doCaseOfCase fc x xalts xdef alts def
updateAlt (MkConAlt n ci t args sc)
= MkConAlt n ci t args $
CConCase fc sc
(map (weakenNs (mkSizeOf args)) alts)
(map (weakenNs (mkSizeOf args)) def)
(map (weakensN (mkSizeOf args)) alts)
(map (weakensN (mkSizeOf args)) def)

updateDef : CExp vars -> CExp vars
updateDef sc = CConCase fc sc alts def
Expand Down
10 changes: 5 additions & 5 deletions src/Compiler/Common.idr
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Ord UsePhase where
public export
record CompileData where
constructor MkCompileData
mainExpr : CExp [] -- main expression to execute. This also appears in
mainExpr : CExp [<] -- main expression to execute. This also appears in
-- the definitions below as MN "__mainExpression" 0
-- For incremental compilation and for compiling exported
-- names only, this can be set to 'erased'.
Expand Down Expand Up @@ -152,7 +152,7 @@ getMinimalDef (Coded ns bin)
name <- fromBuf b
let def
= MkGlobalDef fc name (Erased fc Placeholder) [] [] [] [] mul
[] (specified Public) (MkTotality Unchecked IsCovering) False
[<] (specified Public) (MkTotality Unchecked IsCovering) False
[] Nothing refsR False False True
None cdef Nothing [] Nothing
pure (def, Just (ns, bin))
Expand Down Expand Up @@ -351,8 +351,8 @@ getCompileDataWith exports doLazyAnnots phase_in tm_in
traverse (lambdaLift doLazyAnnots) cseDefs
else pure []

let lifted = (mainname, MkLFun [] [] liftedtm) ::
ldefs ++ concat lifted_in
let lifted = (mainname, MkLFun [<] [<] liftedtm) ::
(ldefs ++ concat lifted_in)

anf <- if phase >= ANF
then logTime 2 "Get ANF" $ traverse (\ (n, d) => pure (n, !(toANF d))) lifted
Expand Down Expand Up @@ -408,7 +408,7 @@ getCompileData = getCompileDataWith []

export
compileTerm : {auto c : Ref Ctxt Defs} ->
ClosedTerm -> Core (CExp [])
ClosedTerm -> Core (CExp [<])
compileTerm tm_in
= do tm <- toFullNames tm_in
fixArityExp !(compileExp tm)
Expand Down
Loading