This PR shifts the conversion from LCNF mono to lambda pure into the LCNF impure phase. This is preparatory work for the upcoming refactor of IR into LCNF impure. The LCNF impure phase differs from the other LCNF phases in two crucial ways: 1. I decided to have `Decl.type` be the result type as opposed to an arrows from the parameter types to the result type. This is done because impure does not have a notion of arrows anymore so keeping them around for this one particular purpose would be slightly odd. 2. In order to avoid cluttering up the olean size LCNF impure saves only the signature persistently to the disk. This is possible because we no longer have inlining/specialization at this point of compilation so all we need is typing information (and potentially other environment extensions) to guide our analyses.
24 lines
783 B
Text
24 lines
783 B
Text
[Compiler.saveMono] size: 9
|
||
def g._redArg (n : Nat) (a : lcAny) (f : lcAny → lcAny) : lcAny :=
|
||
let zero := 0;
|
||
let isZero := Nat.decEq n zero;
|
||
cases isZero : lcAny
|
||
| Bool.true =>
|
||
return a
|
||
| Bool.false =>
|
||
let one := 1;
|
||
let n.1 := Nat.sub n one;
|
||
let _x.2 := g._redArg n.1 a f;
|
||
let _x.3 := f _x.2;
|
||
return _x.3
|
||
[Compiler.saveMono] size: 1
|
||
def g (α : ◾) (n : Nat) (a : lcAny) (b : lcAny) (f : lcAny → lcAny) : lcAny :=
|
||
let _x.1 := g._redArg n a f;
|
||
return _x.1
|
||
[Compiler.saveMono] size: 4
|
||
def h (n : Nat) (a : Nat) : Nat :=
|
||
let _x.1 := double;
|
||
let _x.2 := g._redArg n a _x.1;
|
||
let _x.3 := g._redArg a n _x.1;
|
||
let _x.4 := Nat.add _x.2 _x.3;
|
||
return _x.4
|