koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.16k stars 151 forks source link

canonicalize lambda c representation within modules #343

Closed TimWhiting closed 4 months ago

TimWhiting commented 12 months ago

Previous to the split core: The .koka folder after running stack test wc -l * Goes from 4690331 to 4196774. ~ 10% reduction in generated code

With the new splitted core and implicits this is not as effective, only a 2% reduction in generated code: 856525 total 839587 total

To address this properly, we ought to create a core representation that lifts all lambdas to first order functions with their associated closure state, and then address closure state drop-reuse along with closure state canonicalization, and do the canonicalization across modules (reusing canonical closure state types from dependent modules).