├── .gitignore ├── LICENSE.txt ├── README.md ├── demo ├── 2ltt.cabal ├── 2ltt.el ├── Common.hs ├── Cxt.hs ├── Elaboration.hs ├── Errors.hs ├── Evaluation.hs ├── LICENSE ├── Main.hs ├── MainInteraction.hs ├── Metacontext.hs ├── Parser.hs ├── Presyntax.hs ├── Pretty.hs ├── README.md ├── Staging.hs ├── Syntax.hs ├── Tests.hs ├── Unification.hs ├── Value.hs ├── examples │ ├── FoldrFusion.2ltt │ ├── STLC.2ltt │ ├── Tutorial.2ltt │ ├── Vectors.2ltt │ ├── camnotes.2ltt │ ├── mitplprez.2ltt │ ├── new.2ltt │ └── notes.2ltt ├── package.yaml └── stack.yaml ├── dept23prez ├── AndrasKovacs_dws23.pdf ├── prez.fdb_latexmk ├── prez.nav ├── prez.snm ├── prez.tex ├── prez.txt ├── prez.vrb └── prez.xdv ├── hipe-doc ├── AIM37prez.txt ├── Bench.hs ├── Bench.s ├── HPHL.md ├── Notes.hs ├── Notes.hss ├── Notes2.hs ├── Notes2.s ├── boquist.pdf ├── cnotes ├── cnotes.c ├── cnotes.s ├── csabanotes.txt ├── ghc │ └── Bench.hs ├── koka │ └── bench.kk ├── lazy-by-default │ ├── foo.rs │ └── notes.md ├── lean4 │ ├── maptest.c │ ├── maptest.lean │ ├── notes.c │ └── notes.lean ├── notes.c ├── notes.s ├── ocaml │ ├── bench.cmi │ ├── bench.cmx │ └── bench.ml ├── pinned.c ├── pinned.s ├── result-mprotect.txt ├── sigbench ├── sigbench.cpp ├── stagedabs │ ├── Gen.hs │ ├── GenNoCurry.hs │ ├── NoCurry.md │ ├── Tests.hs │ ├── hsver │ │ ├── Gen.hs │ │ ├── Gen2.hs │ │ ├── Gen3.hs │ │ ├── Gen4.hs │ │ ├── GenNoCurry.hs │ │ ├── GenNoCurry2.hs │ │ ├── GenNoCurry3.hs │ │ ├── GenNoCurry4.hs │ │ ├── Notes.agda │ │ ├── Sugar.h │ │ ├── Tests.hs │ │ ├── Translate.agda │ │ └── Up.hs │ ├── objectlang.txt │ ├── stagedlang.md │ └── stagedlang2.md ├── stagedlang.md ├── zero_cost_gc.md └── zero_cost_gc2.md ├── icfp22paper ├── ACM-Reference-Format.bst ├── ACM-Reference-Format.cbx ├── ACM-Reference-Format.dbx ├── acmart.cls ├── acmart.dtx ├── acmart.ins ├── appendix.bbl ├── appendix.pdf ├── appendix.tex ├── arxivsub │ ├── acmart.cls │ ├── paper.bbl │ └── paper.tex ├── comment.cut ├── notes.txt ├── notes2.txt ├── paper.bbl ├── paper.blg ├── paper.fdb_latexmk ├── paper.pdf ├── paper.tex ├── papersub │ ├── acmart.cls │ ├── paper.bbl │ ├── paper.tex │ └── source.zip ├── references.bib ├── response │ └── notes.txt ├── revisions.pdf ├── revisions.tex └── sub │ ├── demo.zip │ └── demo │ ├── 2ltt.cabal │ ├── Common.hs │ ├── Cxt.hs │ ├── Elaboration.hs │ ├── Errors.hs │ ├── Evaluation.hs │ ├── Main.hs │ ├── Metacontext.hs │ ├── Parser.hs │ ├── Presyntax.hs │ ├── Pretty.hs │ ├── README.md │ ├── Staging.hs │ ├── Syntax.hs │ ├── Tests.hs │ ├── Unification.hs │ ├── Value.hs │ ├── examples │ ├── FoldrFusion.2ltt │ ├── STLC.2ltt │ ├── Tutorial.2ltt │ └── Vectors.2ltt │ ├── package.yaml │ └── stack.yaml ├── icfp22prez ├── ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.fdb_latexmk ├── ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.nav ├── ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.pdf ├── ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.snm ├── ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.tex ├── prez2.fdb_latexmk ├── prez2.nav ├── prez2.pdf └── prez2.snm ├── icfp24paper ├── ACM-Reference-Format.bst ├── README.md ├── acmart.cls ├── artifact.zip ├── paper.bbl ├── paper.blg ├── paper.fdb_latexmk ├── paper.pdf ├── paper.tex ├── permission_release.pdf ├── references.bib ├── smallexample │ └── Object.agda ├── submission │ ├── ACM-Reference-Format.bst │ ├── acmart.cls │ ├── paper.bbl │ ├── paper.tex │ ├── references.bib │ └── sources.zip └── supplement │ ├── README.md │ ├── agda-cftt │ ├── Examples.agda │ ├── Gen.agda │ ├── Improve.agda │ ├── Join.agda │ ├── Lib.agda │ ├── Object.agda │ ├── Pull.agda │ ├── README.agda │ ├── SOP.agda │ ├── Split.agda │ └── agda-cftt.agda-lib │ ├── agda-ifip-tailcall │ ├── Examples.agda │ ├── Gen.agda │ ├── Improve.agda │ ├── Join.agda │ ├── Lib.agda │ ├── Object.agda │ ├── PullM.agda │ ├── README.agda │ ├── SOP.agda │ └── Split.agda │ ├── agda-opsem │ ├── Bisimilarities.agda │ ├── Bisimilarity.agda │ ├── Interpreter.agda │ ├── Lib.agda │ ├── README.agda │ ├── Renaming.agda │ ├── Syntax.agda │ └── agda-cftt-opsem.agda-lib │ └── haskell-cftt │ ├── CFTT │ ├── Examples.hs │ ├── Gen.hs │ ├── Improve.hs │ ├── Join.hs │ ├── Pull.hs │ ├── SOP.hs │ ├── Split.hs │ ├── Tree.hs │ └── Up.hs │ ├── README.md │ ├── haskell-cftt.cabal │ ├── package.yaml │ └── stack.yaml ├── icfp24prez ├── abstract.bbl ├── abstract.blg ├── abstract.fdb_latexmk ├── abstract.pdf ├── abstract.tex ├── easychair.cls ├── pres │ ├── AndrásKovács.pdf │ ├── Notes.hs │ ├── newprez.fdb_latexmk │ ├── newprez.nav │ ├── newprez.pdf │ ├── newprez.snm │ ├── newprez.tex │ ├── newprez.vrb │ ├── newprez.xdv │ ├── notes.txt │ └── references.bib └── references.bib ├── newnotes ├── intensional.txt └── norm.txt ├── old ├── efop_abstract │ ├── abstract.bbl │ ├── abstract.pdf │ ├── abstract.tex │ ├── easychair.cls │ ├── efopprez.txt │ ├── ext_abstract.aux │ ├── ext_abstract.fdb_latexmk │ ├── ext_abstract.fls │ ├── ext_abstract.log │ ├── ext_abstract.out │ ├── ext_abstract.pdf │ ├── ext_abstract.tex │ ├── ext_abstract.zip │ └── references.bib ├── icfp24_old │ ├── diff.pdf │ ├── foobar │ │ ├── submission │ │ │ ├── README.md │ │ │ ├── agda-cftt │ │ │ │ ├── Examples.agda │ │ │ │ ├── Gen.agda │ │ │ │ ├── Improve.agda │ │ │ │ ├── Join.agda │ │ │ │ ├── Lib.agda │ │ │ │ ├── MonadTailCall.agda │ │ │ │ ├── Object.agda │ │ │ │ ├── Pull.agda │ │ │ │ ├── README.agda │ │ │ │ ├── SOP.agda │ │ │ │ └── Split.agda │ │ │ ├── agda-opsem │ │ │ │ ├── Bisimilarities.agda │ │ │ │ ├── Bisimilarity.agda │ │ │ │ ├── Interpreter.agda │ │ │ │ ├── Lib.agda │ │ │ │ ├── README.agda │ │ │ │ ├── Renaming.agda │ │ │ │ └── Syntax.agda │ │ │ └── haskell-cftt │ │ │ │ ├── CFTT │ │ │ │ ├── Examples.hs │ │ │ │ ├── Gen.hs │ │ │ │ ├── Improve.hs │ │ │ │ ├── Join.hs │ │ │ │ ├── MonadTailCall.hs │ │ │ │ ├── Pull.hs │ │ │ │ ├── SOP.hs │ │ │ │ ├── Split.hs │ │ │ │ ├── Tree.hs │ │ │ │ └── Up.hs │ │ │ │ ├── README.md │ │ │ │ ├── package.yaml │ │ │ │ └── stack.yaml │ │ └── supplement.zip │ ├── hs-agda │ │ ├── agda-ifip-no-tailcall │ │ │ ├── Examples.agda │ │ │ ├── Gen.agda │ │ │ ├── Improve.agda │ │ │ ├── Join.agda │ │ │ ├── Lib.agda │ │ │ ├── Object.agda │ │ │ ├── Pull.agda │ │ │ ├── README.agda │ │ │ ├── SOP.agda │ │ │ └── Split.agda │ │ ├── agda-ifip-tailcall │ │ │ ├── Examples.agda │ │ │ ├── Gen.agda │ │ │ ├── Improve.agda │ │ │ ├── Join.agda │ │ │ ├── Lib.agda │ │ │ ├── Object.agda │ │ │ ├── Pull.agda │ │ │ ├── PullM.agda │ │ │ ├── README.agda │ │ │ ├── SOP.agda │ │ │ └── Split.agda │ │ └── haskell-cftt │ │ │ └── haskell-cftt.cabal │ ├── paper_oldsub.pdf │ ├── response.txt │ ├── responses.txt │ ├── retreatprez │ │ ├── newprez.fdb_latexmk │ │ ├── newprez.nav │ │ ├── newprez.pdf │ │ ├── newprez.snm │ │ ├── newprez.tex │ │ ├── newprez.vrb │ │ ├── newprez.xdv │ │ └── references.bib │ └── types24 │ │ ├── AndrásKovács.pdf │ │ ├── newprez.fdb_latexmk │ │ ├── newprez.nav │ │ ├── newprez.pdf │ │ ├── newprez.snm │ │ ├── newprez.tex │ │ ├── newprez.vrb │ │ ├── newprez.xdv │ │ └── references.bib ├── mono_staged │ ├── LICENSE │ ├── Test.mstt │ ├── package.yaml │ ├── src │ │ ├── Common.hs │ │ ├── Cxt.hs │ │ ├── Cxt │ │ │ ├── Extension.hs │ │ │ ├── Fields.hs │ │ │ └── Types.hs │ │ ├── ElabState.hs │ │ ├── Elaboration.hs │ │ ├── Evaluation.hs │ │ ├── Exceptions.hs │ │ ├── InCxt.hs │ │ ├── Lexer.hs │ │ ├── LvlSet.hs │ │ ├── Parser.hs │ │ ├── Plans.md │ │ ├── Presyntax.hs │ │ ├── Pretty.hs │ │ ├── Syntax.hs │ │ ├── Unification.hs │ │ ├── UnifyCxt.hs │ │ └── Values.hs │ ├── stack.yaml │ ├── staged-fp.cabal │ └── staged │ │ ├── Main.hs │ │ └── preznotes.txt ├── notes │ ├── 2022jan24.txt │ ├── ClosedMonadicEval.hs │ ├── FixFusion.hs │ ├── Fusion.agda │ ├── Fusion.hs │ ├── Fusion2.agda │ ├── Fusion3.agda │ ├── FusionNotes.agda │ ├── GHCComp.dump-llvm │ ├── GHCComp.hs │ ├── GHCComp.s │ ├── Hyper.hs │ ├── MonadicNBE.hs │ ├── Objects.md │ ├── Objects2.md │ ├── RTSNOTES.txt │ ├── a.out │ ├── autofuse.txt │ ├── clobber.c │ ├── clobber.ll │ ├── clobber.s │ ├── elabnotes.txt │ ├── gccnotes │ ├── gccnotes.c │ ├── gccnotes.s │ ├── gcnotes.c │ ├── gcnotes.ll │ ├── gcnotes.s │ ├── generalnotes.txt │ ├── icfp99.ps │ ├── inline_asm │ ├── inline_asm.c │ ├── inline_asm.s │ ├── llvmconfignotes.txt │ ├── llvmnotes │ ├── llvmnotes.c │ ├── llvmnotes.ll │ ├── llvmnotes.s │ ├── newprez.txt │ ├── notes │ ├── notes.c │ ├── notes.ll │ ├── prez.txt │ ├── prez2.txt │ ├── rts │ ├── rts.c │ ├── rts.s │ ├── rtsclang.c │ ├── rtsclang.ll │ ├── rtsclang.s │ ├── sections.c │ ├── sections.s │ ├── stagenotes.mstt │ ├── structret.c │ ├── structret.ll │ └── structret.s ├── references │ ├── CFA_for_FP.pdf │ ├── Denis Bakhvalov - Performance Analysis and Tuning on Modern CPUs.pdf │ ├── Germane-Adams2020_Chapter_LiberateAbstractGarbageCollect.pdf │ ├── Hack_Sebastian.pdf │ ├── a-practical-mode-system-for-recursive-definitions.pdf │ ├── generating-mutually-recursive-definitions-short-paper.pdf │ ├── ilik-2013.pdf │ ├── inlining.pdf │ ├── let-rec-insertion-without-effects-lights-or-magic.pdf │ ├── linear_ssa.pdf │ ├── tdpe.pdf │ └── thesis.pdf ├── tkp_prez │ ├── Notes.hs │ ├── notes.mstt │ └── notes2.mstt └── types2021 │ ├── EasyChair3.5 │ ├── chairEC.pdf │ ├── debug.pdf │ ├── easychair.bib │ ├── easychair.cls │ ├── easychair.pdf │ ├── easychair.tex │ ├── epic.pdf │ ├── logoEC.pdf │ └── throneEC.jpg │ ├── abstract.aux │ ├── abstract.bbl │ ├── abstract.blg │ ├── abstract.fdb_latexmk │ ├── abstract.fls │ ├── abstract.log │ ├── abstract.out │ ├── abstract.pdf │ ├── abstract.tex │ ├── easychair.cls │ ├── easychair.zip │ ├── prez │ ├── AndrasKovacs.pdf │ ├── prez.aux │ ├── prez.bbl │ ├── prez.blg │ ├── prez.fdb_latexmk │ ├── prez.fls │ ├── prez.log │ ├── prez.nav │ ├── prez.out │ ├── prez.pdf │ ├── prez.snm │ ├── prez.tex │ ├── prez.toc │ ├── prez.vrb │ ├── prez.xdv │ ├── references.bib │ └── script.txt │ └── references.bib ├── opt ├── ANF.agda ├── CSE1.hs ├── CSE2.hs ├── CSE3.hs ├── HOASANF.hs ├── HOASANF2.hs ├── HOASANF3.hs ├── HOASANF4.hs ├── HOASANF5.hs ├── HOASANF6.hs ├── HOASLVL.hs ├── HOASLVL2.hs ├── HOASLVL3.hs ├── HOASLVL4.hs ├── HOASLVL5.hs ├── HOASLVL6.hs ├── HOASLVL7.hs ├── Polarized1.hs ├── Polarized2.hs ├── SimpleANF.hs ├── SimpleANF2.hs ├── new │ ├── agda-src-lang │ │ ├── Bisimilarities.agda │ │ ├── Bisimilarity.agda │ │ ├── Interpreter.agda │ │ ├── Lib.agda │ │ ├── README.agda │ │ ├── Renaming.agda │ │ ├── Syntax.agda │ │ └── agda-cftt-opsem.agda-lib │ └── anf-examples │ │ ├── 1-minimal.hs │ │ ├── 2-anf-output.hs │ │ └── 3-switch-branch-labels.hs ├── newnotes.txt └── notes.txt ├── partially_static ├── Notes.agda ├── notes.txt ├── paper │ ├── ACM-Reference-Format.bst │ ├── acmart-primary │ │ ├── .gitignore │ │ ├── ACM-Reference-Format.bst │ │ ├── Makefile │ │ ├── README │ │ ├── acm-jdslogo.png │ │ ├── acmart.bib │ │ ├── acmart.dtx │ │ ├── acmart.ins │ │ ├── acmauthoryear.bbx │ │ ├── acmauthoryear.cbx │ │ ├── acmdatamodel.dbx │ │ ├── acmnumeric.bbx │ │ ├── acmnumeric.cbx │ │ └── samples │ │ │ ├── abbrev.bib │ │ │ ├── sample-base.bib │ │ │ ├── sample-franklin.png │ │ │ ├── samples.dtx │ │ │ ├── samples.ins │ │ │ ├── sampleteaser.pdf │ │ │ └── software.bib │ ├── acmart.cls │ ├── comment.cut │ ├── paper.bbl │ ├── paper.blg │ ├── paper.fdb_latexmk │ ├── paper.pdf │ ├── paper.tex │ └── references.bib ├── partially_static.md └── refs │ ├── btime_improv.pdf │ ├── generic-partially-static-data.pdf │ ├── jonesgomardsestoft-letter.pdf │ ├── partially-static-data-as-free-extension-of-algebras.pdf │ ├── seminar20220719_staging_partially_static.svg │ ├── stagedData.ps │ ├── tagless.pdf │ └── thiemann2013.pdf ├── rts ├── RegionGraph.md ├── RegionGraph2.md └── RegionGraph3.md ├── runtime_codegen ├── agda │ ├── Embedding.agda │ ├── Lib.agda │ ├── Notes.agda │ ├── Substitution.agda │ └── Syntax.agda ├── notes.txt ├── proto │ ├── Main.hs │ ├── README.md │ ├── example.txt │ ├── mltt-runtime-codegen.cabal │ ├── old │ │ ├── Main.hs │ │ └── Main2.hs │ ├── package.yaml │ └── stack.yaml └── proto2 │ ├── Common.hs │ ├── Compiler.hs │ ├── Cxt.hs │ ├── Cxt │ └── Type.hs │ ├── ElabState.hs │ ├── Elaboration.hs │ ├── Errors.hs │ ├── Evaluation.hs │ ├── Interpreter.hs │ ├── Main.hs │ ├── Notes.agda │ ├── Parser.hs │ ├── Presyntax.hs │ ├── Pretty.hs │ ├── README.md │ ├── StringBuilder.hs │ ├── Syntax.hs │ ├── TODO.txt │ ├── Value.hs │ ├── Zonk.hs │ ├── debug.rtcg │ ├── out.js │ ├── package-lock.json │ ├── package.json │ ├── package.yaml │ ├── poly_examples.rtcg │ ├── positive_pattern_unif.md │ ├── rtcg.cabal │ ├── rtcg.el │ ├── rts.js │ ├── stack.yaml │ ├── test1.rtcg │ ├── test2.rtcg │ ├── test3.rtcg │ ├── test4.rtcg │ └── test5.rtcg ├── stackalloc └── Notes.agda ├── thinningPSh ├── Notes.agda └── notes.txt ├── tkp22prez ├── andras_kovacs_tkp_prez.aux ├── andras_kovacs_tkp_prez.fdb_latexmk ├── andras_kovacs_tkp_prez.fls ├── andras_kovacs_tkp_prez.log ├── andras_kovacs_tkp_prez.nav ├── andras_kovacs_tkp_prez.out ├── andras_kovacs_tkp_prez.pdf ├── andras_kovacs_tkp_prez.snm ├── andras_kovacs_tkp_prez.tex ├── andras_kovacs_tkp_prez.toc ├── prez.aux ├── prez.fdb_latexmk ├── prez.fls ├── prez.log ├── prez.nav ├── prez.out ├── prez.pdf ├── prez.snm └── prez.toc ├── tkp23prez ├── tkp23prez.fdb_latexmk ├── tkp23prez.nav ├── tkp23prez.pdf ├── tkp23prez.snm └── tkp23prez.tex ├── types2022 ├── abstract.aux ├── abstract.bbl ├── abstract.blg ├── abstract.fdb_latexmk ├── abstract.fls ├── abstract.log ├── abstract.out ├── abstract.pdf ├── abstract.tex ├── easychair.cls ├── prez │ ├── ConservativityStaging-AndrásKovács.pdf │ ├── prez.fdb_latexmk │ ├── prez.nav │ ├── prez.pdf │ ├── prez.snm │ └── prez.tex └── references.bib ├── types2024 ├── abstract.bbl ├── abstract.blg ├── abstract.fdb_latexmk ├── abstract.pdf ├── abstract.tex ├── easychair.cls ├── pres │ ├── AndrásKovács.pdf │ ├── newprez.fdb_latexmk │ ├── newprez.nav │ ├── newprez.pdf │ ├── newprez.snm │ ├── newprez.tex │ ├── newprez.vrb │ ├── newprez.xdv │ └── references.bib └── references.bib └── yonedaLF ├── Informal.txt ├── Model.txt ├── Model2.txt ├── Model3.txt ├── Model4.txt ├── Model5.txt ├── Model6.txt ├── Model7.txt ├── Model8.txt ├── PShSetInternalization.txt ├── TreeModel.txt ├── awodey_hsuniv.pdf ├── christian.txt ├── draft ├── ACM-Reference-Format.bst ├── acmart-primary │ ├── .gitignore │ ├── ACM-Reference-Format.bst │ ├── Makefile │ ├── README │ ├── acm-jdslogo.png │ ├── acmart-tagged.cls │ ├── acmart.bib │ ├── acmart.dtx │ ├── acmart.ins │ ├── acmauthoryear.bbx │ ├── acmauthoryear.cbx │ ├── acmdatamodel.dbx │ ├── acmnumeric.bbx │ ├── acmnumeric.cbx │ └── samples │ │ ├── abbrev.bib │ │ ├── acmengage.dtx │ │ ├── sample-acmsmall-tagged-luamml-mathml.html │ │ ├── sample-base.bib │ │ ├── sample-franklin.png │ │ ├── samples.dtx │ │ ├── samples.ins │ │ ├── sampleteaser.pdf │ │ └── software.bib ├── acmart-tagged.cls ├── comment.cut ├── paper.fdb_latexmk ├── paper.pdf ├── paper.tex └── references.bib ├── old ├── EvenNewer.txt ├── Model.txt ├── NewYonedaLF.txt ├── NewYonedaLF2.txt ├── NewYonedaLF3.txt ├── NominalContexts.md ├── NominalContexts2.md ├── NominalContexts3.txt ├── NominalContexts4.txt ├── OldModelYetAgain.txt ├── YonedaLF.md └── YonedaTT.txt ├── prez.txt ├── types2025 ├── EasyChair3.5 │ ├── chairEC.pdf │ ├── debug.pdf │ ├── easychair.bib │ ├── easychair.cls │ ├── easychair.pdf │ ├── easychair.tex │ ├── epic.pdf │ ├── logoEC.pdf │ └── throneEC.jpg ├── abstract.bbl ├── abstract.blg ├── abstract.fdb_latexmk ├── abstract.pdf ├── abstract.tex ├── easychair.cls ├── easychair.zip └── references.bib └── wg6_2025 ├── AndrasKovacs.pdf ├── prez.fdb_latexmk ├── prez.nav ├── prez.pdf ├── prez.snm ├── prez.tex └── references.bib /.gitignore: -------------------------------------------------------------------------------- 1 | *.hi 2 | *.dyn_hi 3 | *.dyn_o 4 | *.o 5 | ./dist 6 | .stack-work/ 7 | *# 8 | TAGS 9 | *.lock 10 | *.dump-simpl 11 | *.dump-cmm 12 | *.dump-stg 13 | *.agdai 14 | *.aux 15 | *.lof 16 | *.log 17 | *.lot 18 | *.fls 19 | *.out 20 | *.toc 21 | *.fmt 22 | *.fot 23 | *.cb 24 | *.cb2 25 | .*.lb 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2025 András Kovács 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # staged 2 | 3 | Staged compilation with two-level type theory. 4 | 5 | - [ICFP 2024 paper](https://andraskovacs.github.io/pdfs/2ltt_icfp24.pdf). [Code supplement](https://github.com/AndrasKovacs/staged/tree/main/icfp24paper/supplement). 6 | - [ICFP 2022 paper](https://andraskovacs.github.io/pdfs/2ltt.pdf). Includes a proof of correctness of staging. [Appendix](https://andraskovacs.github.io/pdfs/2ltt_appendix.pdf). [Demo implementation](demo), together with a tutorial and some code examples. Has an efficient staging implementation and powerful inference for stage annotations. 7 | 8 | Older material, somewhat obsolete now: 9 | 10 | - [Abstract at the TYPES 2021 conference](https://types21.liacs.nl/wp-content/uploads/2021/06/book.pdf#page=83). 11 | - [Slightly longer abstract, discussing generativity](efop_abstract/ext_abstract.pdf). 12 | - Videos: 13 | - https://www.youtube.com/watch?v=ove4TQsXemY 14 | - https://www.youtube.com/watch?v=WOd0ZFbJfQg 15 | - https://www.youtube.com/watch?v=ai4vU1Naopk 16 | -------------------------------------------------------------------------------- /demo/2ltt.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.34.4. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: 2ltt 8 | version: 0.1.0.0 9 | description: Small implementation of a two-level type theory, for demonstrating staged compilation 10 | category: Language 11 | homepage: https://github.com/AndrasKovacs/staged#readme 12 | bug-reports: https://github.com/AndrasKovacs/staged/issues 13 | author: András Kovács 14 | maintainer: puttamalac@gmail.com 15 | copyright: 2022 András Kovács 16 | license: MIT 17 | license-file: LICENSE 18 | build-type: Simple 19 | 20 | source-repository head 21 | type: git 22 | location: https://github.com/AndrasKovacs/staged 23 | 24 | executable 2ltt 25 | main-is: Main.hs 26 | other-modules: 27 | Common 28 | Cxt 29 | Elaboration 30 | Errors 31 | Evaluation 32 | MainInteraction 33 | Metacontext 34 | Parser 35 | Presyntax 36 | Pretty 37 | Staging 38 | Syntax 39 | Tests 40 | Unification 41 | Value 42 | Paths_2ltt 43 | hs-source-dirs: 44 | ./ 45 | default-extensions: 46 | BangPatterns 47 | BlockArguments 48 | ConstraintKinds 49 | DeriveAnyClass 50 | DerivingVia 51 | FlexibleContexts 52 | LambdaCase 53 | PatternSynonyms 54 | StandaloneKindSignatures 55 | Strict 56 | TupleSections 57 | ViewPatterns 58 | ghc-options: -O -rtsopts -with-rtsopts= "-A64M" -Wall -Wno-name-shadowing -Wno-missing-signatures -Wno-unused-do-bind -Wno-unused-matches 59 | build-depends: 60 | base >=4.7 && <5 61 | , containers 62 | , megaparsec 63 | default-language: Haskell2010 64 | -------------------------------------------------------------------------------- /demo/Errors.hs: -------------------------------------------------------------------------------- 1 | 2 | module Errors where 3 | 4 | import Control.Exception 5 | import Text.Printf 6 | 7 | import Common 8 | import Cxt 9 | import Syntax 10 | 11 | -------------------------------------------------------------------------------- 12 | 13 | data UnifyError = UnifyError 14 | deriving (Show, Exception) 15 | 16 | data ElabError 17 | = NameNotInScope Name 18 | | CantUnify Tm Tm 19 | | InferNamedLam 20 | | NoNamedImplicitArg Name 21 | | IcitMismatch Icit Icit 22 | | InferStage 23 | deriving (Show, Exception) 24 | 25 | data Error = Error Cxt ElabError 26 | deriving (Show, Exception) 27 | 28 | displayError :: String -> Error -> IO () 29 | displayError file (Error cxt e) = do 30 | 31 | let SourcePos path (unPos -> linum) (unPos -> colnum) = pos cxt 32 | lnum = show linum 33 | lpad = map (const ' ') lnum 34 | msg = case e of 35 | NameNotInScope x -> 36 | "Name not in scope: " ++ x 37 | CantUnify t t' -> 38 | ("Cannot unify expected type\n\n" ++ 39 | " " ++ showTm cxt V1 t' ++ "\n\n" ++ 40 | "with inferred type\n\n" ++ 41 | " " ++ showTm cxt V1 t) 42 | InferNamedLam -> 43 | "Cannot infer type for lambda with named argument" 44 | NoNamedImplicitArg name -> 45 | "No named implicit argument with name " ++ name 46 | IcitMismatch i i' -> printf ( 47 | "Function icitness mismatch: expected %s, got %s.") 48 | (show i) (show i') 49 | InferStage -> 50 | "Cannot infer stage" 51 | 52 | printf "%s:%d:%d:\n" path linum colnum 53 | printf "%s |\n" lpad 54 | printf "%s | %s\n" lnum (lines file !! (linum - 1)) 55 | printf "%s | %s\n" lpad (replicate (colnum - 1) ' ' ++ "^") 56 | printf "%s\n" msg 57 | -------------------------------------------------------------------------------- /demo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 András Kovács 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /demo/Main.hs: -------------------------------------------------------------------------------- 1 | 2 | module Main where 3 | 4 | import qualified MainInteraction 5 | 6 | main :: IO () 7 | main = MainInteraction.main 8 | -------------------------------------------------------------------------------- /demo/Metacontext.hs: -------------------------------------------------------------------------------- 1 | 2 | module Metacontext where 3 | 4 | import Data.IORef 5 | import System.IO.Unsafe 6 | import qualified Data.IntMap as IM 7 | 8 | import Common 9 | import Value 10 | 11 | -------------------------------------------------------------------------------- 12 | 13 | data MetaEntry 14 | = Solved Val ~VTy Stage -- ^ Solution, type. 15 | | Unsolved ~VTy Stage -- ^ Type. 16 | 17 | nextMetaVar :: IORef MetaVar 18 | nextMetaVar = unsafeDupablePerformIO $ newIORef 0 19 | {-# noinline nextMetaVar #-} 20 | 21 | newMeta :: VTy -> Stage -> IO MetaVar 22 | newMeta ~a st = do 23 | m <- readIORef nextMetaVar 24 | writeIORef nextMetaVar $! m + 1 25 | modifyIORef mcxt $ IM.insert (coerce m) (Unsolved a st) 26 | pure m 27 | 28 | type MCxt = IM.IntMap MetaEntry 29 | 30 | mcxt :: IORef MCxt 31 | mcxt = unsafeDupablePerformIO $ newIORef mempty 32 | {-# noinline mcxt #-} 33 | 34 | readMeta :: MetaVar -> IO MetaEntry 35 | readMeta m = do 36 | ms <- readIORef mcxt 37 | case IM.lookup (coerce m) ms of 38 | Just e -> pure e 39 | Nothing -> impossible 40 | 41 | lookupMeta :: MetaVar -> MetaEntry 42 | lookupMeta = unsafeDupablePerformIO . readMeta 43 | 44 | -- | Reset all mutable refs to initial state. 45 | reset :: IO () 46 | reset = do 47 | writeIORef nextMetaVar 0 48 | writeIORef mcxt mempty 49 | -------------------------------------------------------------------------------- /demo/Presyntax.hs: -------------------------------------------------------------------------------- 1 | 2 | module Presyntax where 3 | 4 | import Common 5 | 6 | data Tm 7 | = Var Name -- x 8 | | Lam Name (Maybe Tm) (Either Name Icit) Tm -- \x. t | \{x}. t | \{x = y}. t 9 | | App Tm Tm (Either Name Icit) -- t u | t {u} | t {x = u} 10 | | U Stage -- U i 11 | | Pi Name Icit Tm Tm -- (x : A) -> B | {x : A} -> B 12 | | Let Stage Name (Maybe Tm) Tm Tm -- let x : A := t; u | let x : A = t; u 13 | | Pos (DontShow SourcePos) Tm -- source position for error reporting 14 | | Hole -- _ 15 | | Lift Tm -- ^A 16 | | Quote Tm -- 17 | | Splice Tm -- [t] 18 | 19 | | Nat Stage -- Nat0 | Nat1 20 | | Zero Stage -- zero0 | zero1 21 | | Suc Stage -- suc0 | suc1 22 | | NatElim Stage -- NatElim0 | NatElim1 23 | deriving Show 24 | -------------------------------------------------------------------------------- /demo/Value.hs: -------------------------------------------------------------------------------- 1 | 2 | module Value where 3 | 4 | import Common 5 | 6 | type Env = [Val] 7 | type VTy = Val 8 | 9 | data Spine 10 | = SId 11 | | SApp Spine ~Val Icit Verbosity 12 | | SSplice Spine 13 | | SNatElim Stage Val Val Val Spine 14 | 15 | data Val 16 | = VFlex MetaVar Spine 17 | | VRigid Lvl Spine 18 | | VLam Name Icit ~VTy (Val -> Val) Verbosity 19 | | VPi Name Icit ~VTy (Val -> Val) 20 | | VU Stage 21 | | VLift Val 22 | | VQuote Val 23 | | VNat Stage 24 | | VZero Stage 25 | | VSuc Stage Val 26 | 27 | pattern VVar :: Lvl -> Val 28 | pattern VVar x = VRigid x SId 29 | 30 | pattern VMeta :: MetaVar -> Val 31 | pattern VMeta m = VFlex m SId 32 | 33 | infixr 3 ==> 34 | (==>) :: VTy -> VTy -> VTy 35 | a ==> b = VPi "_" Expl a (\_ -> b) 36 | 37 | vlamE0 :: Name -> VTy -> (Val -> Val) -> Val 38 | vlamE0 x a t = VLam x Expl a t V0 39 | 40 | vpiE :: Name -> VTy -> (Val -> Val) -> Val 41 | vpiE x = VPi x Expl 42 | -------------------------------------------------------------------------------- /demo/examples/new.2ltt: -------------------------------------------------------------------------------- 1 | 2 | -- U0 is the type of object types, U0 : U0 3 | -- U1 is the type of metatypes, U1 : U1 4 | 5 | -- U1 → U1 : U1 6 | -- {A : U1} → A → A : U1 7 | 8 | {- 9 | Staging operations: 10 | 11 | - A : U0 then ↑A : U1 ("lift", the type of metaprograms that generate A-typed expressions) 12 | - t : A : U0 then : ↑A ("quotation", metaprogram which immediately returns an expression) 13 | - t : ↑A then [t] : A ("splice", run metaprogram, insert output into expression) 14 | - [] ≡ t 15 | - <[t]> ≡ t 16 | -} 17 | 18 | -- let typeInType0 : U0 := U0; 19 | 20 | let typeInType1 : U1 = U1; 21 | 22 | let typeInType0 : U0 := U0; 23 | 24 | -- let three := suc0 (suc0 (suc0 zero0)); 25 | 26 | let three = suc0 (suc0 (suc0 zero0)); -- inline definition 27 | 28 | 29 | let id : {A : U1} → A → A = λ x. x; 30 | 31 | let four := id (id three); 32 | 33 | 34 | 35 | U0 36 | -------------------------------------------------------------------------------- /demo/package.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: 2ltt 3 | version: 0.1.0.0 4 | license: MIT 5 | author: "András Kovács" 6 | maintainer: "puttamalac@gmail.com" 7 | copyright: "2022 András Kovács" 8 | category: Language 9 | description: "Small implementation of a two-level type theory, for demonstrating staged compilation" 10 | bug-reports: https://github.com/AndrasKovacs/staged/issues 11 | github: AndrasKovacs/staged 12 | 13 | default-extensions: 14 | - BangPatterns 15 | - BlockArguments 16 | - ConstraintKinds 17 | - DeriveAnyClass 18 | - DerivingVia 19 | - FlexibleContexts 20 | - LambdaCase 21 | - PatternSynonyms 22 | - StandaloneKindSignatures 23 | - Strict 24 | - TupleSections 25 | - ViewPatterns 26 | 27 | executable: 28 | source-dirs: . 29 | main: Main.hs 30 | dependencies: 31 | - base >= 4.7 && < 5 32 | - containers 33 | - megaparsec 34 | ghc-options: 35 | - -O 36 | - -rtsopts 37 | - -with-rtsopts= "-A64M" 38 | - -Wall 39 | - -Wno-name-shadowing 40 | - -Wno-missing-signatures 41 | - -Wno-unused-do-bind 42 | - -Wno-unused-matches 43 | -------------------------------------------------------------------------------- /demo/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | resolver: lts-22.9 3 | -------------------------------------------------------------------------------- /dept23prez/AndrasKovacs_dws23.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/dept23prez/AndrasKovacs_dws23.pdf -------------------------------------------------------------------------------- /dept23prez/prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/7}{}{0}} 6 | \headcommand {\beamer@framepages {5}{7}} 7 | \headcommand {\slideentry {0}{0}{4}{8/11}{}{0}} 8 | \headcommand {\beamer@framepages {8}{11}} 9 | \headcommand {\slideentry {0}{0}{5}{12/12}{}{0}} 10 | \headcommand {\beamer@framepages {12}{12}} 11 | \headcommand {\slideentry {0}{0}{6}{13/16}{}{0}} 12 | \headcommand {\beamer@framepages {13}{16}} 13 | \headcommand {\slideentry {0}{0}{7}{17/18}{}{0}} 14 | \headcommand {\beamer@framepages {17}{18}} 15 | \headcommand {\slideentry {0}{0}{8}{19/19}{}{0}} 16 | \headcommand {\beamer@framepages {19}{19}} 17 | \headcommand {\slideentry {0}{0}{9}{20/20}{}{0}} 18 | \headcommand {\beamer@framepages {20}{20}} 19 | \headcommand {\slideentry {0}{0}{10}{21/21}{}{0}} 20 | \headcommand {\beamer@framepages {21}{21}} 21 | \headcommand {\beamer@partpages {1}{21}} 22 | \headcommand {\beamer@subsectionpages {1}{21}} 23 | \headcommand {\beamer@sectionpages {1}{21}} 24 | \headcommand {\beamer@documentpages {21}} 25 | \headcommand {\gdef \inserttotalframenumber {10}} 26 | -------------------------------------------------------------------------------- /dept23prez/prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/dept23prez/prez.snm -------------------------------------------------------------------------------- /dept23prez/prez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Defunctionalization} 2 | 3 | No functions needed: 4 | \vspace{1em} 5 | 6 | \begin{exampleblock}{} 7 | \begin{verbatim} 8 | data DList a = Chunk [a] | Append (DList a) (DList a) 9 | 10 | apply :: DList a -> [a] -> [a] 11 | apply (Chunk xs) ys = xs ++ ys 12 | apply (Append xs ys) zs = apply xs (apply ys zs) 13 | 14 | toDList :: [a] -> DList a 15 | toDList xs = Chunk xs 16 | 17 | fromDList :: DList a -> [a] 18 | fromDList xs = apply xs [] 19 | \end{verbatim} 20 | \end{exampleblock} 21 | -------------------------------------------------------------------------------- /dept23prez/prez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/dept23prez/prez.xdv -------------------------------------------------------------------------------- /hipe-doc/Bench.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# language UnliftedNewtypes, UnliftedDatatypes, StandaloneKindSignatures, LambdaCase, 3 | UnboxedTuples, MagicHash, PatternSynonyms #-} 4 | 5 | module Bench where 6 | 7 | import GHC.Exts 8 | 9 | type Tm :: UnliftedType 10 | data Tm = Var Int# | App Tm Tm | Lam Tm 11 | 12 | type Env :: UnliftedType 13 | data Env = Nil | Cons Env Val 14 | 15 | type Val :: UnliftedType 16 | data Val = VVar Int# | VLam Env Tm | VApp Val Val 17 | 18 | newtype UBool = UBool Int# 19 | 20 | pattern UTrue = UBool 1# 21 | pattern UFalse = UBool 0# 22 | 23 | infixl 8 $$ 24 | ($$) = App 25 | 26 | uand :: UBool -> UBool -> UBool 27 | uand UTrue y = y 28 | uand x y = y 29 | 30 | var :: Env -> Int# -> Val 31 | var (Cons _ v) 0# = v 32 | var (Cons e _) x = var e (x -# 1#) 33 | var _ _ = undefined 34 | 35 | eval :: Env -> Tm -> Val 36 | eval env = \case 37 | Var x -> var env x 38 | App t u -> case eval env t of 39 | VLam e' t -> eval (Cons e' (eval env u)) t 40 | t -> VApp t (eval env u) 41 | Lam t -> VLam env t 42 | 43 | conv :: Int# -> Val -> Val -> UBool 44 | conv x t u = case (# t, u #) of 45 | (# VVar x, VVar x' #) -> UBool (x ==# x') 46 | (# VLam e t, VLam e' t' #) -> 47 | let v = VVar x in 48 | conv (x +# 1#) (eval (Cons e v) t) (eval (Cons e' v) t') 49 | (# VApp t u, VApp t' u' #) -> 50 | uand (conv x t t') (conv x u u') 51 | (# t, VLam e t' #) -> conv (x +# 1#) t (eval (Cons e (VVar x)) t') 52 | (# VLam e t, t' #) -> conv (x +# 1#) (eval (Cons e (VVar x)) t) t' 53 | _ -> UFalse 54 | 55 | let_ :: Tm -> Tm -> Tm 56 | let_ t u = App (Lam t) u 57 | {-# inline let_ #-} 58 | 59 | pattern V0 = Var 0# 60 | pattern V1 = Var 1# 61 | pattern V2 = Var 2# 62 | pattern V3 = Var 3# 63 | pattern V4 = Var 4# 64 | pattern V5 = Var 5# 65 | -------------------------------------------------------------------------------- /hipe-doc/boquist.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/hipe-doc/boquist.pdf -------------------------------------------------------------------------------- /hipe-doc/cnotes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/hipe-doc/cnotes -------------------------------------------------------------------------------- /hipe-doc/cnotes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void foo(uint64_t f) { 5 | __attribute__ ((musttail)) return ((void (*)(uint64_t))f)(100); 6 | } 7 | 8 | int main(){return 0;} 9 | -------------------------------------------------------------------------------- /hipe-doc/cnotes.s: -------------------------------------------------------------------------------- 1 | .text 2 | .file "cnotes.c" 3 | .globl foo # -- Begin function foo 4 | .p2align 4, 0x90 5 | .type foo,@function 6 | foo: # @foo 7 | .cfi_startproc 8 | # %bb.0: 9 | movq %rdi, %rax 10 | movl $100, %edi 11 | jmpq *%rax # TAILCALL 12 | .Lfunc_end0: 13 | .size foo, .Lfunc_end0-foo 14 | .cfi_endproc 15 | # -- End function 16 | .globl main # -- Begin function main 17 | .p2align 4, 0x90 18 | .type main,@function 19 | main: # @main 20 | .cfi_startproc 21 | # %bb.0: 22 | xorl %eax, %eax 23 | retq 24 | .Lfunc_end1: 25 | .size main, .Lfunc_end1-main 26 | .cfi_endproc 27 | # -- End function 28 | .ident "Ubuntu clang version 14.0.0-1ubuntu1" 29 | .section ".note.GNU-stack","",@progbits 30 | .addrsig 31 | -------------------------------------------------------------------------------- /hipe-doc/csabanotes.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /hipe-doc/lazy-by-default/foo.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fn foo(x : u64, y : u64) -> Option { 5 | if y == 0 { 6 | None 7 | } else { 8 | Some(x / y) 9 | } 10 | } 11 | 12 | fn main(){ 13 | match foo(20,0){ 14 | Some(x) => println!("{}", x), 15 | None => println!("kek") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hipe-doc/lean4/maptest.lean: -------------------------------------------------------------------------------- 1 | 2 | def mymap (xs : List UInt64) := 3 | match xs with 4 | | [] => [] 5 | | x :: xs => (x + 100) :: mymap xs -------------------------------------------------------------------------------- /hipe-doc/notes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | struct Tree { 5 | uint64_t ptr; // tagged pointer, Leaf: 0 tag, Node: 1 tag 6 | }; 7 | 8 | typedef struct Tree Tree; 9 | 10 | struct Node { 11 | Tree left; 12 | Tree right; 13 | }; 14 | 15 | typedef struct Node Node; 16 | 17 | struct Leaf { 18 | uint64_t field; 19 | }; 20 | 21 | typedef struct Leaf Leaf; 22 | 23 | struct Res{ 24 | Tree res; 25 | uint64_t* hp; 26 | }; 27 | 28 | typedef struct Res Res; 29 | 30 | inline Res leaf(uint64_t* hp, uint64_t field) { 31 | hp[0] = field; 32 | Res res = {{(uint64_t) hp}, hp + 1}; 33 | return res; 34 | } 35 | 36 | inline Res node(uint64_t* hp, Tree l, Tree r){ 37 | ((Tree*)hp)[0] = l; 38 | ((Tree*)hp)[1] = r; 39 | Res res = {{(uint64_t)hp | 1}, hp + 2}; 40 | return res; 41 | } 42 | 43 | inline Leaf* toLeaf(Tree t){ 44 | return (Leaf*)(t.ptr); // 0 last bit 45 | } 46 | 47 | inline Node* toNode(Tree t){ 48 | return (Node*)(t.ptr - 1); // 1 last bit 49 | } 50 | 51 | Res foo (uint64_t* hp, Tree t){ 52 | uint64_t tag = t.ptr & 1; 53 | 54 | // Leaf 55 | if (tag == 0) { 56 | return leaf(hp, toLeaf(t)->field + 10); 57 | 58 | // Node 59 | } else { 60 | Node* n = toNode(t); 61 | Res r1 = foo(hp, n->left); 62 | Res r2 = foo(r1.hp, n->right); 63 | return node(r2.hp, r1.res, r2.res); 64 | } 65 | } 66 | 67 | int main(){} 68 | -------------------------------------------------------------------------------- /hipe-doc/notes.s: -------------------------------------------------------------------------------- 1 | .file "notes.c" 2 | .text 3 | .p2align 4 4 | .globl foo 5 | .type foo, @function 6 | foo: 7 | .LFB4: 8 | endbr64 9 | testb $1, %sil 10 | jne .L2 11 | movq (%rsi), %rax 12 | leaq 8(%rdi), %rdx 13 | addq $10, %rax 14 | movq %rax, (%rdi) 15 | movq %rdi, %rax 16 | ret 17 | .L2: 18 | pushq %rbp 19 | leaq -1(%rsi), %rbp 20 | pushq %rbx 21 | subq $8, %rsp 22 | movq -1(%rsi), %rsi 23 | call foo 24 | movq 8(%rbp), %rsi 25 | movq %rdx, %rdi 26 | movq %rax, %rbx 27 | call foo 28 | movq %rax, 8(%rdx) 29 | movq %rdx, %rax 30 | addq $16, %rdx 31 | movq %rbx, -16(%rdx) 32 | addq $8, %rsp 33 | orq $1, %rax 34 | popq %rbx 35 | popq %rbp 36 | ret 37 | .cfi_endproc 38 | .LFE4: 39 | .size foo, .-foo 40 | .section .text.startup,"ax",@progbits 41 | .p2align 4 42 | .globl main 43 | .type main, @function 44 | main: 45 | .LFB5: 46 | .cfi_startproc 47 | endbr64 48 | xorl %eax, %eax 49 | ret 50 | .cfi_endproc 51 | .LFE5: 52 | .size main, .-main 53 | .ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0" 54 | .section .note.GNU-stack,"",@progbits 55 | .section .note.gnu.property,"a" 56 | .align 8 57 | .long 1f - 0f 58 | .long 4f - 1f 59 | .long 5 60 | 0: 61 | .string "GNU" 62 | 1: 63 | .align 8 64 | .long 0xc0000002 65 | .long 3f - 2f 66 | 2: 67 | .long 0x3 68 | 3: 69 | .align 8 70 | 4: 71 | -------------------------------------------------------------------------------- /hipe-doc/ocaml/bench.cmi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/hipe-doc/ocaml/bench.cmi -------------------------------------------------------------------------------- /hipe-doc/ocaml/bench.cmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/hipe-doc/ocaml/bench.cmx -------------------------------------------------------------------------------- /hipe-doc/pinned.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | register uint64_t* hp asm ("r12"); 6 | 7 | typedef struct Tree { 8 | uint64_t ptr; // tagged pointer, Leaf: 0 tag, Node: 1 tag 9 | } Tree; 10 | 11 | typedef struct Node { 12 | Tree left; 13 | Tree right; 14 | } Node; 15 | 16 | typedef struct Leaf { 17 | uint64_t field; 18 | } Leaf; 19 | 20 | typedef struct Leaf Leaf; 21 | 22 | inline Tree leaf(uint64_t field) { 23 | uint64_t* oldhp = hp; 24 | hp[0] = field; 25 | hp += 1; 26 | return (Tree){(uint64_t) oldhp}; 27 | } 28 | 29 | inline Tree node(Tree l, Tree r){ 30 | uint64_t* oldhp = hp; 31 | ((Tree*)hp)[0] = l; 32 | ((Tree*)hp)[1] = r; 33 | hp += 2; 34 | return (Tree){(uint64_t)oldhp | 1}; 35 | } 36 | 37 | inline Leaf* toLeaf(Tree t){ 38 | return (Leaf*)(t.ptr); // 0 last bit 39 | } 40 | 41 | inline Node* toNode(Tree t){ 42 | return (Node*)(t.ptr - 1); // 1 last bit 43 | } 44 | 45 | Tree foo (Tree t){ 46 | uint64_t* oldhp = hp; 47 | uint64_t tag = t.ptr & 1; 48 | 49 | // Leaf 50 | if (tag == 0) { 51 | return leaf(toLeaf(t)->field + 10); 52 | 53 | // Node 54 | } else { 55 | Node* n = toNode(t); 56 | Tree l2 = foo(n->left); 57 | Tree l3 = foo(n->right); 58 | return node(l2, l3); 59 | } 60 | } 61 | 62 | int main(){} 63 | -------------------------------------------------------------------------------- /hipe-doc/sigbench: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/hipe-doc/sigbench -------------------------------------------------------------------------------- /hipe-doc/stagedabs/hsver/Notes.agda: -------------------------------------------------------------------------------- 1 | 2 | {-# OPTIONS --type-in-type #-} 3 | 4 | open import Data.Product 5 | open import Function 6 | 7 | module _ (S A : Set) where 8 | data PT : Set 9 | data Res : Set 10 | 11 | data PT where 12 | con : (S → Res × S) → PT 13 | 14 | data Res where 15 | nothing : Res 16 | just : A → PT → Res 17 | 18 | append : PT → PT → PT 19 | append (con xs) (con ys) = 20 | con λ s → case xs s of λ { (nothing , s) → ys s 21 | ; (just x xs , s) → (just x (append xs (con ys))) , s} 22 | -------------------------------------------------------------------------------- /hipe-doc/stagedabs/hsver/Sugar.h: -------------------------------------------------------------------------------- 1 | 2 | #define Q(X) ([||X||] :: Up _) 3 | -------------------------------------------------------------------------------- /icfp22paper/ACM-Reference-Format.cbx: -------------------------------------------------------------------------------- 1 | \ProvidesFile{ACM-Reference-Format.cbx}[2017-09-27 v0.1] 2 | 3 | \RequireCitationStyle{numeric} 4 | 5 | \endinput 6 | -------------------------------------------------------------------------------- /icfp22paper/ACM-Reference-Format.dbx: -------------------------------------------------------------------------------- 1 | % Teach biblatex about numpages field 2 | \DeclareDatamodelFields[type=field, datatype=literal]{numpages} 3 | \DeclareDatamodelEntryfields{numpages} 4 | 5 | % Teach biblatex about articleno field 6 | \DeclareDatamodelFields[type=field, datatype=literal]{articleno} 7 | \DeclareDatamodelEntryfields{articleno} 8 | 9 | % Teach biblatex about urls field 10 | \DeclareDatamodelFields[type=list, datatype=uri]{urls} 11 | \DeclareDatamodelEntryfields{urls} 12 | 13 | % Teach biblatex about school field 14 | \DeclareDatamodelFields[type=list, datatype=literal]{school} 15 | \DeclareDatamodelEntryfields[thesis]{school} 16 | 17 | \DeclareDatamodelFields[type=field, datatype=literal]{key} 18 | \DeclareDatamodelEntryfields{key} -------------------------------------------------------------------------------- /icfp22paper/acmart.ins: -------------------------------------------------------------------------------- 1 | % 2 | % Doctrip file for acmart 3 | % This file is in public domain 4 | % $Id: acmart.ins,v 1.1 2015/11/23 22:42:55 boris Exp $ 5 | % 6 | \def\batchfile{acmart.ins} 7 | \input docstrip 8 | \keepsilent 9 | \showprogress 10 | 11 | 12 | \askforoverwritefalse 13 | 14 | \generate{% 15 | \file{acmart.cls}{\from{acmart.dtx}{class}} 16 | } 17 | 18 | \obeyspaces 19 | \Msg{*****************************************************}% 20 | \Msg{* Congratulations! You successfully generated the *}% 21 | \Msg{* acmart package. *}% 22 | \Msg{* *}% 23 | \Msg{* Please move the file acmart.cls to where LaTeX *}% 24 | \Msg{* files are stored in your system. The manual is *}% 25 | \Msg{* acmart.pdf. *}% 26 | \Msg{* *}% 27 | \Msg{* The package is released under LPPL *}% 28 | \Msg{* *}% 29 | \Msg{* Happy TeXing! *}% 30 | \Msg{*****************************************************}% -------------------------------------------------------------------------------- /icfp22paper/appendix.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22paper/appendix.pdf -------------------------------------------------------------------------------- /icfp22paper/comment.cut: -------------------------------------------------------------------------------- 1 | To Robert, for the bagels and explaining CMYK and color spaces. 2 | -------------------------------------------------------------------------------- /icfp22paper/paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22paper/paper.pdf -------------------------------------------------------------------------------- /icfp22paper/papersub/source.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22paper/papersub/source.zip -------------------------------------------------------------------------------- /icfp22paper/revisions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22paper/revisions.pdf -------------------------------------------------------------------------------- /icfp22paper/sub/demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22paper/sub/demo.zip -------------------------------------------------------------------------------- /icfp22paper/sub/demo/2ltt.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.34.4. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: 2ltt 8 | version: 0.1.0.0 9 | description: Small implementation of a two-level type theory, for demonstrating staged compilation 10 | category: Language 11 | license: MIT 12 | license-file: LICENSE 13 | build-type: Simple 14 | 15 | executable 2ltt 16 | main-is: Main.hs 17 | other-modules: 18 | Common 19 | Cxt 20 | Elaboration 21 | Errors 22 | Evaluation 23 | Metacontext 24 | Parser 25 | Presyntax 26 | Pretty 27 | Staging 28 | Syntax 29 | Tests 30 | Unification 31 | Value 32 | Paths_2ltt 33 | hs-source-dirs: 34 | ./ 35 | default-extensions: 36 | BangPatterns 37 | BlockArguments 38 | ConstraintKinds 39 | ConstraintKinds 40 | DeriveAnyClass 41 | DerivingVia 42 | EmptyCase 43 | FlexibleContexts 44 | GeneralizedNewtypeDeriving 45 | LambdaCase 46 | OverloadedStrings 47 | PatternSynonyms 48 | ScopedTypeVariables 49 | StandaloneDeriving 50 | StandaloneKindSignatures 51 | Strict 52 | TupleSections 53 | ViewPatterns 54 | ghc-options: -Wall -Wno-name-shadowing -Wno-missing-signatures -Wno-unused-do-bind -Wno-unused-matches -O -rtsopts -with-rtsopts= "-A64M" 55 | build-depends: 56 | base >=4.7 && <5 57 | , containers 58 | , megaparsec 59 | default-language: Haskell2010 60 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/Errors.hs: -------------------------------------------------------------------------------- 1 | 2 | module Errors where 3 | 4 | import Control.Exception 5 | import Text.Printf 6 | 7 | import Common 8 | import Cxt 9 | import Syntax 10 | 11 | -------------------------------------------------------------------------------- 12 | 13 | data UnifyError = UnifyError 14 | deriving (Show, Exception) 15 | 16 | data ElabError 17 | = NameNotInScope Name 18 | | CantUnify Tm Tm 19 | | InferNamedLam 20 | | NoNamedImplicitArg Name 21 | | IcitMismatch Icit Icit 22 | | InferStage 23 | deriving (Show, Exception) 24 | 25 | data Error = Error Cxt ElabError 26 | deriving (Show, Exception) 27 | 28 | displayError :: String -> Error -> IO () 29 | displayError file (Error cxt e) = do 30 | 31 | let SourcePos path (unPos -> linum) (unPos -> colnum) = pos cxt 32 | lnum = show linum 33 | lpad = map (const ' ') lnum 34 | msg = case e of 35 | NameNotInScope x -> 36 | "Name not in scope: " ++ x 37 | CantUnify t t' -> 38 | ("Cannot unify expected type\n\n" ++ 39 | " " ++ showTm cxt V1 t' ++ "\n\n" ++ 40 | "with inferred type\n\n" ++ 41 | " " ++ showTm cxt V1 t) 42 | InferNamedLam -> 43 | "Cannot infer type for lambda with named argument" 44 | NoNamedImplicitArg name -> 45 | "No named implicit argument with name " ++ name 46 | IcitMismatch i i' -> printf ( 47 | "Function icitness mismatch: expected %s, got %s.") 48 | (show i) (show i') 49 | InferStage -> 50 | "Cannot infer stage" 51 | 52 | printf "%s:%d:%d:\n" path linum colnum 53 | printf "%s |\n" lpad 54 | printf "%s | %s\n" lnum (lines file !! (linum - 1)) 55 | printf "%s | %s\n" lpad (replicate (colnum - 1) ' ' ++ "^") 56 | printf "%s\n" msg 57 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/Metacontext.hs: -------------------------------------------------------------------------------- 1 | 2 | module Metacontext where 3 | 4 | import Data.IORef 5 | import System.IO.Unsafe 6 | import qualified Data.IntMap as IM 7 | 8 | import Common 9 | import Value 10 | 11 | -------------------------------------------------------------------------------- 12 | 13 | data MetaEntry 14 | = Solved Val ~VTy Stage -- ^ Solution, type. 15 | | Unsolved ~VTy Stage -- ^ Type. 16 | 17 | nextMetaVar :: IORef MetaVar 18 | nextMetaVar = unsafeDupablePerformIO $ newIORef 0 19 | {-# noinline nextMetaVar #-} 20 | 21 | newMeta :: VTy -> Stage -> IO MetaVar 22 | newMeta ~a st = do 23 | m <- readIORef nextMetaVar 24 | writeIORef nextMetaVar $! m + 1 25 | modifyIORef mcxt $ IM.insert (coerce m) (Unsolved a st) 26 | pure m 27 | 28 | type MCxt = IM.IntMap MetaEntry 29 | 30 | mcxt :: IORef MCxt 31 | mcxt = unsafeDupablePerformIO $ newIORef mempty 32 | {-# noinline mcxt #-} 33 | 34 | readMeta :: MetaVar -> IO MetaEntry 35 | readMeta m = do 36 | ms <- readIORef mcxt 37 | case IM.lookup (coerce m) ms of 38 | Just e -> pure e 39 | Nothing -> impossible 40 | 41 | lookupMeta :: MetaVar -> MetaEntry 42 | lookupMeta = unsafeDupablePerformIO . readMeta 43 | 44 | -- | Reset all mutable refs to initial state. 45 | reset :: IO () 46 | reset = do 47 | writeIORef nextMetaVar 0 48 | writeIORef mcxt mempty 49 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/Presyntax.hs: -------------------------------------------------------------------------------- 1 | 2 | module Presyntax where 3 | 4 | import Common 5 | 6 | data Tm 7 | = Var Name -- x 8 | | Lam Name (Maybe Tm) (Either Name Icit) Tm -- \x. t | \{x}. t | \{x = y}. t 9 | | App Tm Tm (Either Name Icit) -- t u | t {u} | t {x = u} 10 | | U Stage -- U i 11 | | Pi Name Icit Tm Tm -- (x : A) -> B | {x : A} -> B 12 | | Let Stage Name (Maybe Tm) Tm Tm -- let x : A := t; u | let x : A = t; u 13 | | Pos (DontShow SourcePos) Tm -- source position for error reporting 14 | | Hole -- _ 15 | | Lift Tm -- ^A 16 | | Quote Tm -- 17 | | Splice Tm -- [t] 18 | 19 | | Nat Stage -- Nat0 | Nat1 20 | | Zero Stage -- zero0 | zero1 21 | | Suc Stage -- suc0 | suc1 22 | | NatElim Stage -- NatElim0 | NatElim1 23 | deriving Show 24 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/Value.hs: -------------------------------------------------------------------------------- 1 | 2 | module Value where 3 | 4 | import Common 5 | 6 | type Env = [Val] 7 | type VTy = Val 8 | 9 | data Spine 10 | = SId 11 | | SApp Spine ~Val Icit Verbosity 12 | | SSplice Spine 13 | | SNatElim Stage Val Val Val Spine 14 | 15 | data Val 16 | = VFlex MetaVar Spine 17 | | VRigid Lvl Spine 18 | | VLam Name Icit ~VTy (Val -> Val) Verbosity 19 | | VPi Name Icit ~VTy (Val -> Val) 20 | | VU Stage 21 | | VLift Val 22 | | VQuote Val 23 | | VNat Stage 24 | | VZero Stage 25 | | VSuc Stage Val 26 | 27 | pattern VVar :: Lvl -> Val 28 | pattern VVar x = VRigid x SId 29 | 30 | pattern VMeta :: MetaVar -> Val 31 | pattern VMeta m = VFlex m SId 32 | 33 | infixr 3 ==> 34 | (==>) :: VTy -> VTy -> VTy 35 | a ==> b = VPi "_" Expl a (\_ -> b) 36 | 37 | vlamE0 :: Name -> VTy -> (Val -> Val) -> Val 38 | vlamE0 x a t = VLam x Expl a t V0 39 | 40 | vpiE :: Name -> VTy -> (Val -> Val) -> Val 41 | vpiE x = VPi x Expl 42 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/package.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: 2ltt 3 | version: 0.1.0.0 4 | # license: 5 | # author: 6 | # maintainer: 7 | # copyright: 8 | category: Language 9 | 10 | description: "Small implementation of a two-level type theory, for demonstrating staged compilation" 11 | 12 | default-extensions: 13 | - BangPatterns 14 | - BlockArguments 15 | - ConstraintKinds 16 | - ConstraintKinds 17 | - DeriveAnyClass 18 | - DerivingVia 19 | - EmptyCase 20 | - FlexibleContexts 21 | - GeneralizedNewtypeDeriving 22 | - LambdaCase 23 | - OverloadedStrings 24 | - PatternSynonyms 25 | - ScopedTypeVariables 26 | - StandaloneDeriving 27 | - StandaloneKindSignatures 28 | - Strict 29 | - TupleSections 30 | - ViewPatterns 31 | 32 | ghc-options: 33 | - -Wall 34 | - -Wno-name-shadowing 35 | - -Wno-missing-signatures 36 | - -Wno-unused-do-bind 37 | - -Wno-unused-matches 38 | 39 | dependencies: 40 | - base >= 4.7 && < 5 41 | - containers 42 | - megaparsec 43 | 44 | source-dirs: . 45 | 46 | executable: 47 | main: Main.hs 48 | ghc-options: 49 | - -O 50 | - -rtsopts 51 | - -with-rtsopts= "-A64M" 52 | -------------------------------------------------------------------------------- /icfp22paper/sub/demo/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | resolver: lts-18.26 3 | -------------------------------------------------------------------------------- /icfp22prez/ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/11}{}{0}} 6 | \headcommand {\beamer@framepages {5}{11}} 7 | \headcommand {\slideentry {0}{0}{4}{12/14}{}{0}} 8 | \headcommand {\beamer@framepages {12}{14}} 9 | \headcommand {\slideentry {0}{0}{5}{15/21}{}{0}} 10 | \headcommand {\beamer@framepages {15}{21}} 11 | \headcommand {\slideentry {0}{0}{6}{22/23}{}{0}} 12 | \headcommand {\beamer@framepages {22}{23}} 13 | \headcommand {\slideentry {0}{0}{7}{24/25}{}{0}} 14 | \headcommand {\beamer@framepages {24}{25}} 15 | \headcommand {\slideentry {0}{0}{8}{26/28}{}{0}} 16 | \headcommand {\beamer@framepages {26}{28}} 17 | \headcommand {\slideentry {0}{0}{9}{29/30}{}{0}} 18 | \headcommand {\beamer@framepages {29}{30}} 19 | \headcommand {\slideentry {0}{0}{10}{31/32}{}{0}} 20 | \headcommand {\beamer@framepages {31}{32}} 21 | \headcommand {\slideentry {0}{0}{11}{33/34}{}{0}} 22 | \headcommand {\beamer@framepages {33}{34}} 23 | \headcommand {\slideentry {0}{0}{12}{35/36}{}{0}} 24 | \headcommand {\beamer@framepages {35}{36}} 25 | \headcommand {\slideentry {0}{0}{13}{37/38}{}{0}} 26 | \headcommand {\beamer@framepages {37}{38}} 27 | \headcommand {\slideentry {0}{0}{14}{39/39}{}{0}} 28 | \headcommand {\beamer@framepages {39}{39}} 29 | \headcommand {\beamer@partpages {1}{39}} 30 | \headcommand {\beamer@subsectionpages {1}{39}} 31 | \headcommand {\beamer@sectionpages {1}{39}} 32 | \headcommand {\beamer@documentpages {39}} 33 | \headcommand {\gdef \inserttotalframenumber {14}} 34 | -------------------------------------------------------------------------------- /icfp22prez/ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22prez/ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.pdf -------------------------------------------------------------------------------- /icfp22prez/ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22prez/ICFP-Kovács-StagedCompilationwithTwoLevelTypeTheory.snm -------------------------------------------------------------------------------- /icfp22prez/prez2.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/11}{}{0}} 6 | \headcommand {\beamer@framepages {5}{11}} 7 | \headcommand {\slideentry {0}{0}{4}{12/14}{}{0}} 8 | \headcommand {\beamer@framepages {12}{14}} 9 | \headcommand {\slideentry {0}{0}{5}{15/21}{}{0}} 10 | \headcommand {\beamer@framepages {15}{21}} 11 | \headcommand {\slideentry {0}{0}{6}{22/23}{}{0}} 12 | \headcommand {\beamer@framepages {22}{23}} 13 | \headcommand {\slideentry {0}{0}{7}{24/25}{}{0}} 14 | \headcommand {\beamer@framepages {24}{25}} 15 | \headcommand {\slideentry {0}{0}{8}{26/28}{}{0}} 16 | \headcommand {\beamer@framepages {26}{28}} 17 | \headcommand {\slideentry {0}{0}{9}{29/30}{}{0}} 18 | \headcommand {\beamer@framepages {29}{30}} 19 | \headcommand {\slideentry {0}{0}{10}{31/32}{}{0}} 20 | \headcommand {\beamer@framepages {31}{32}} 21 | \headcommand {\slideentry {0}{0}{11}{33/34}{}{0}} 22 | \headcommand {\beamer@framepages {33}{34}} 23 | \headcommand {\slideentry {0}{0}{12}{35/36}{}{0}} 24 | \headcommand {\beamer@framepages {35}{36}} 25 | \headcommand {\slideentry {0}{0}{13}{37/38}{}{0}} 26 | \headcommand {\beamer@framepages {37}{38}} 27 | \headcommand {\slideentry {0}{0}{14}{39/39}{}{0}} 28 | \headcommand {\beamer@framepages {39}{39}} 29 | \headcommand {\beamer@partpages {1}{39}} 30 | \headcommand {\beamer@subsectionpages {1}{39}} 31 | \headcommand {\beamer@sectionpages {1}{39}} 32 | \headcommand {\beamer@documentpages {39}} 33 | \headcommand {\gdef \inserttotalframenumber {14}} 34 | -------------------------------------------------------------------------------- /icfp22prez/prez2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22prez/prez2.pdf -------------------------------------------------------------------------------- /icfp22prez/prez2.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp22prez/prez2.snm -------------------------------------------------------------------------------- /icfp24paper/README.md: -------------------------------------------------------------------------------- 1 | Sources for the paper "Closure-Free Functional Programming in a Two-Level Type Theory", to appear at ICFP 2024. 2 | 3 | [Paper](https://andraskovacs.github.io/pdfs/2ltt_icfp24.pdf). [Code](supplement). 4 | -------------------------------------------------------------------------------- /icfp24paper/artifact.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24paper/artifact.zip -------------------------------------------------------------------------------- /icfp24paper/paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24paper/paper.pdf -------------------------------------------------------------------------------- /icfp24paper/permission_release.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24paper/permission_release.pdf -------------------------------------------------------------------------------- /icfp24paper/submission/sources.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24paper/submission/sources.zip -------------------------------------------------------------------------------- /icfp24paper/supplement/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Supplement to the paper "Closure-Free Functional Programming in a Two-Level Type Theory" 3 | 4 | This supplement consists of three separate artifacts: 5 | 6 | - `agda-cftt`: implements the paper in Agda, using a precise embedding of the 7 | object language as postulated higher-order abstract syntax. In particular, 8 | computation and value types are tracked. 9 | - `haskell-cftt`: implements the paper in typed Template Haskell. Does not 10 | track computation and value types. 11 | - `agda-opsem`: formalizes a syntax and operational semantics for the object 12 | theory and develops some basic metatheory for it. 13 | - `agda-ifip-tailcall`: not discussed in the paper. Extends `agda-cftt` with monadic tail calls and effectful streams. 14 | 15 | In each folder, build instructions and further documentation can be found in the 16 | local README-s and the source files. 17 | -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-cftt/Improve.agda: -------------------------------------------------------------------------------- 1 | 2 | module Improve where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import Split 8 | 9 | -- paper 3.3 10 | record Improve (F : VTy → Ty) (M : Set → Set) : Set₁ where 11 | field 12 | ⦃ MGM ⦄ : MonadGen M 13 | up : ∀ {A} → ↑ (F A) → M (↑V A) 14 | down : ∀ {A} → M (↑V A) → ↑ (F A) 15 | open Improve ⦃...⦄ public 16 | 17 | instance 18 | ImpIdentity : Improve Identity∘ Gen 19 | Improve.up ImpIdentity x = pure (runIdentity∘ x) 20 | Improve.down ImpIdentity x = runGen (identity∘ <$> x) 21 | 22 | ImpMaybeT : ∀ {F M} → ⦃ _ : Improve F M ⦄ → Improve (MaybeT∘ F) (MaybeT M) 23 | Improve.up ImpMaybeT x = maybeT do x ← up (runMaybeT∘ x); split x 24 | Improve.down ImpMaybeT (maybeT x) = maybeT∘ $ down do 25 | x >>= λ where 26 | nothing → pure nothing∘ 27 | (just a) → pure (just∘ a) 28 | 29 | ImpStateT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (StateT∘ S F) (StateT (↑V S) M) 30 | Improve.up ImpStateT x = stateT λ s → do as ← up (runStateT∘ x s); split as 31 | Improve.down ImpStateT (stateT x) = stateT∘ λ s → down (do (a , s) ← x s; pure (a ,∘ s)) 32 | 33 | ImpReaderT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (ReaderT∘ S F) (ReaderT (↑V S) M) 34 | Improve.up ImpReaderT x = readerT (up ∘ runReaderT∘ x) 35 | Improve.down ImpReaderT (readerT x) = readerT∘ (down ∘ x) 36 | -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-cftt/Split.agda: -------------------------------------------------------------------------------- 1 | 2 | module Split where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | 8 | -- paper 3.3.1 9 | -------------------------------------------------------------------------------- 10 | 11 | record Split (A : VTy) : Set₁ where 12 | field 13 | SplitTo : Set 14 | splitGen : ↑V A → Gen SplitTo 15 | 16 | split : ∀ {M}⦃ _ : MonadGen M ⦄ → ↑V A → M SplitTo 17 | split a = liftGen (splitGen a) 18 | 19 | caseM : ∀ {M B}⦃ _ : MonadGen M ⦄ → ↑V A → (SplitTo → M B) → M B 20 | caseM a f = do x ← split a; f x 21 | open Split ⦃...⦄ public 22 | 23 | data SplitListTy (A : VTy) : Set where 24 | nil : SplitListTy A 25 | cons : ↑V A → ↑V (List∘ A) → SplitListTy A 26 | 27 | data SplitTreeTy (A : VTy) : Set where 28 | leaf : SplitTreeTy A 29 | node : ↑V A → ↑V (Tree∘ A) → ↑V (Tree∘ A) → SplitTreeTy A 30 | 31 | instance 32 | SplitBool : Split Bool∘ 33 | Split.SplitTo SplitBool = Bool 34 | Split.splitGen SplitBool x = gen λ k → caseBool∘ x (k true) (k false) 35 | 36 | SplitMaybe : ∀ {A} → Split (Maybe∘ A) 37 | Split.SplitTo (SplitMaybe {A}) = Maybe (↑V A) 38 | Split.splitGen SplitMaybe x = gen λ k → caseMaybe∘ x (k nothing) (λ a → k (just a)) 39 | 40 | SplitList : ∀ {A} → Split (List∘ A) 41 | Split.SplitTo (SplitList {A}) = SplitListTy A 42 | Split.splitGen (SplitList {A}) x = gen λ k → caseList∘ x (k nil) λ a as → k (cons a as) 43 | 44 | Split× : ∀ {A B} → Split (A ×∘ B) 45 | Split.SplitTo (Split× {A} {B}) = ↑V A × ↑V B 46 | Split.splitGen Split× x = gen λ k → case×∘ x λ a b → k (a , b) 47 | 48 | SplitTree : ∀ {A} → Split (Tree∘ A) 49 | Split.SplitTo (SplitTree {A}) = SplitTreeTy A 50 | Split.splitGen SplitTree x = gen λ k → caseTree∘ x (k leaf) (λ x l r → k (node x l r)) 51 | -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-cftt/agda-cftt.agda-lib: -------------------------------------------------------------------------------- 1 | name: agda-cftt 2 | include: . 3 | depend: standard-library-2.2 4 | flags: -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-ifip-tailcall/Join.agda: -------------------------------------------------------------------------------- 1 | 2 | module Join where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import SOP 8 | 9 | -- tabulation for continuations 10 | -------------------------------------------------------------------------------- 11 | 12 | FunSOP↑ : Uₛ → Ty → Set 13 | FunSOP↑ [] R = ⊤ 14 | FunSOP↑ (A ∷ B) R = ↑C (A →PT R) × FunSOP↑ B R 15 | 16 | index : ∀ {A B} → FunSOP↑ A B → Elₛ A → ↑ B 17 | index fs (here x) = appₚₜ (fs .₁) x 18 | index fs (there x) = index (fs .₂) x 19 | 20 | tabulate : ∀ {A B} → (Elₛ A → ↑ B) → FunSOP↑ A B 21 | tabulate {[]} f = tt 22 | tabulate {A ∷ B} f = lamₚₜ (f ∘ here) , tabulate (f ∘ there) 23 | 24 | genFunSOP↑ : ∀ {A B} → FunSOP↑ A B → Gen ⊥ (FunSOP↑ A B) 25 | genFunSOP↑ {[]} fs = pure tt 26 | genFunSOP↑ {A ∷ B} (f , fs) = _,_ <$> genLet f <*> genFunSOP↑ {B} fs 27 | 28 | -------------------------------------------------------------------------------- 29 | 30 | record MonadJoin (M : Set → Set) : Set₁ where 31 | field 32 | join : ∀ {A} ⦃ _ : IsSOP A ⦄ → M A → M A 33 | open MonadJoin ⦃...⦄ public 34 | 35 | instance 36 | MonadJoinGen : ∀ {E} → MonadJoin (Gen E) 37 | MonadJoin.join MonadJoinGen ma = gen λ l r → 38 | unGen (genFunSOP↑ (tabulate (r ∘ decode))) (λ ()) λ conts → 39 | unGen ma l λ a → 40 | index conts (encode a) 41 | 42 | MonadJoinMaybeT : ∀ {M}⦃ _ : MonadJoin M ⦄ → MonadJoin (MaybeT M) 43 | MonadJoin.join MonadJoinMaybeT (maybeT ma) = maybeT (join ma) 44 | 45 | MonadJoinReaderT : ∀ {R M}⦃ _ : MonadJoin M ⦄ → MonadJoin (ReaderT R M) 46 | MonadJoin.join MonadJoinReaderT (readerT ma) = readerT (join ∘ ma) 47 | 48 | MonadJoinStateT : ∀ {S M}⦃ _ : MonadJoin M ⦄ ⦃ _ : IsSOP S ⦄ → MonadJoin (StateT S M) 49 | MonadJoin.join MonadJoinStateT (stateT ma) = stateT (join ∘ ma) 50 | -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-ifip-tailcall/README.agda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24paper/supplement/agda-ifip-tailcall/README.agda -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-opsem/Lib.agda: -------------------------------------------------------------------------------- 1 | 2 | module Lib where 3 | 4 | open import Relation.Binary.PropositionalEquality 5 | renaming (subst to tr; sym to infix 5 _⁻¹; trans to infixr 4 _◼_; 6 | cong to ap) 7 | renaming ([_] to hide) 8 | public 9 | 10 | open import Data.Product 11 | renaming (proj₁ to ₁; proj₂ to ₂) 12 | hiding (_<*>_) 13 | public 14 | 15 | open import Data.Maybe hiding (ap; map; zip; zipWith) public 16 | open import Data.Nat hiding (_+_; _*_) public 17 | open import Data.Nat.Properties public 18 | open import Data.Nat.Induction public 19 | open import Function public 20 | open import Data.Unit using (⊤; tt) public 21 | open import Data.Empty public 22 | 23 | -------------------------------------------------------------------------------- 24 | 25 | _⊗_ : 26 | ∀ {α β}{A : Set α}{B : Set β} 27 | {f g : A → B}(p : f ≡ g){a a' : A}(q : a ≡ a') 28 | → f a ≡ g a' 29 | refl ⊗ refl = refl 30 | infixl 8 _⊗_ 31 | 32 | return : ∀ {i}{A : Set i} → A → Maybe A 33 | return = just 34 | 35 | infixl 1 _>>_ 36 | _>>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe A → Maybe B → Maybe B 37 | ma >> mb = ma >>= λ _ → mb 38 | 39 | infixl 4 _<$>_ 40 | _<$>_ : ∀ {i j}{A : Set i}{B : Set j} → (A → B) → Maybe A → Maybe B 41 | f <$> ma = do 42 | a ← ma 43 | just (f a) 44 | 45 | infixl 4 _<*>_ 46 | _<*>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe (A → B) → Maybe A → Maybe B 47 | mf <*> ma = do 48 | f ← mf 49 | a ← ma 50 | just (f a) 51 | -------------------------------------------------------------------------------- /icfp24paper/supplement/agda-opsem/agda-cftt-opsem.agda-lib: -------------------------------------------------------------------------------- 1 | name: agda-cftt-opsem 2 | include: . 3 | depend: standard-library-2.2 4 | flags: 5 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/CFTT/Join.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Join where 3 | 4 | import Data.Kind 5 | import Control.Monad.Except 6 | import Control.Monad.Reader 7 | import Control.Monad.State.Strict 8 | import Control.Monad.Trans.Maybe 9 | 10 | import CFTT.Up 11 | import CFTT.Gen 12 | import CFTT.SOP 13 | 14 | -- paper 3.5 15 | -------------------------------------------------------------------------------- 16 | 17 | -- Functions from Elₛ to Up 18 | type family FunSU (a ∷ Uₛ) (b ∷ Type) ∷ Type where 19 | FunSU '[] b = () 20 | FunSU (a ': as) b = (Up (Funₚₜ a b), FunSU as b) 21 | 22 | tabulate ∷ ∀ a b. Sing a → (Elₛ a → Up b) → FunSU a b 23 | tabulate SNil f = () 24 | tabulate (SCons as ass) f = (lamₚₜ as (f . Here), tabulate ass (f . There)) 25 | 26 | index ∷ FunSU a b → Elₛ a → Up b 27 | index fs (Here x) = appₚₜ (fst fs) x 28 | index fs (There x) = index (snd fs) x 29 | 30 | genFunSU ∷ ∀ a b. Sing a → FunSU a b → Gen (FunSU a b) 31 | genFunSU SNil fs = pure () 32 | genFunSU (SCons a as) fs = (,) <$> gen (fst fs) <*> genFunSU @_ @b as (snd fs) 33 | 34 | class MonadJoin m where 35 | join :: IsSOP a => m a -> m a 36 | 37 | instance MonadJoin Gen where 38 | join ma = Gen \(k :: a -> Up r) -> runGen do 39 | let sa = singRep @a 40 | conts <- genFunSU @_ @r sa (tabulate sa (k . decode)) 41 | a <- ma 42 | pure $ index conts (encode a) 43 | 44 | instance (IsSOP e, MonadJoin m) => MonadJoin (ExceptT e m) where 45 | join (ExceptT ma) = ExceptT $ join ma 46 | 47 | instance (MonadJoin m, IsSOP s) => MonadJoin (StateT s m) where 48 | join (StateT ma) = StateT (join . ma) 49 | 50 | instance MonadJoin m => MonadJoin (MaybeT m) where 51 | join (MaybeT ma) = MaybeT $ join ma 52 | 53 | instance (MonadJoin m) => MonadJoin (ReaderT r m) where 54 | join (ReaderT ma) = ReaderT (join . ma) 55 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/CFTT/Split.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Split where 3 | 4 | import CFTT.Up 5 | import CFTT.Gen 6 | 7 | -- paper 3.3.1 8 | -------------------------------------------------------------------------------- 9 | 10 | class Split a b | a -> b, b -> a where 11 | splitGen :: Up a -> Gen b 12 | 13 | split :: MonadGen m => Split a b => Up a -> m b 14 | split a = liftGen (splitGen a) 15 | 16 | caseM :: (MonadGen m) => Split a b => Up a -> (b -> m c) -> m c 17 | caseM a f = split a >>= f 18 | 19 | instance Split Bool Bool where 20 | splitGen x = Gen \k -> [|| case $$x of 21 | True -> $$(k True) 22 | _ -> $$(k False) ||] 23 | 24 | instance Split [a] (Maybe (Up a, Up [a])) where 25 | splitGen x = Gen \k -> [|| case $$x of 26 | [] -> $$(k Nothing) 27 | a:as -> $$(k (Just ([||a||], [||as||]))) ||] 28 | 29 | instance Split (a, b) (Up a, Up b) where 30 | splitGen x = Gen \k -> [|| case $$x of 31 | (a, b) -> $$(k ([||a||], [||b||])) ||] 32 | 33 | instance Split (Pair a b) (Pair (Up a) (Up b)) where 34 | splitGen x = Gen \k -> [|| case $$x of 35 | Pair a b -> $$(k (Pair [||a||] [||b||])) ||] 36 | 37 | instance Split (Either a b) (Either (Up a) (Up b)) where 38 | splitGen x = Gen \k -> [|| case $$x of 39 | Left a -> $$(k (Left [||a||])) 40 | Right b -> $$(k (Right [||b||])) ||] 41 | 42 | instance Split (Maybe a) (Maybe (Up a)) where 43 | splitGen x = Gen \k -> [|| case $$x of 44 | Nothing -> $$(k Nothing) 45 | Just a -> $$(k (Just [||a||])) ||] 46 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/CFTT/Tree.hs: -------------------------------------------------------------------------------- 1 | {-# language ScopedTypeVariables #-} 2 | 3 | module CFTT.Tree where 4 | 5 | import Data.Typeable 6 | import CFTT.Up 7 | import CFTT.Gen 8 | import CFTT.Split 9 | import CFTT.Pull 10 | import CFTT.SOP 11 | 12 | data Tree a = Leaf | Node a (Tree a) (Tree a) 13 | 14 | instance Split (Tree a) (Maybe (Up a, Up (Tree a), Up (Tree a))) where 15 | splitGen x = Gen \k -> [|| case $$x of 16 | Leaf -> $$(k Nothing) 17 | Node a l r -> $$(k (Just ([||a||], [||l||], [||r||]))) ||] 18 | 19 | instance Typeable a => CasePull (Tree a) (Maybe (Up a, Up (Tree a), Up (Tree a))) where 20 | casePull x f = case (f Nothing, unravel3 (f . Just)) of 21 | (Pull @s skip seed step, Pull' @s' skip' seed' step') -> 22 | Pull @( (Either s (Up a, (Up (Tree a), Up (Tree a)), s'))) (skip || skip') 23 | (caseM x \case Nothing -> Left <$> seed 24 | Just (a, l, r) -> do s' <- seed' $ Cons a $ Cons l $ Cons r Nil 25 | pure $ Right (a, (l, r), s')) 26 | \case 27 | (Left s) -> step s >>= \case 28 | Stop -> pure Stop 29 | Skip s -> pure $ Skip ( (Left s)) 30 | Yield c s -> pure $ Yield c ( (Left s)) 31 | (Right (a, (l, r), s)) -> step' (Cons a $ Cons l $ Cons r Nil) s >>= \case 32 | Stop -> pure Stop 33 | Skip s -> pure $ Skip (Right (a, (l, r), s)) 34 | Yield c s -> pure $ Yield c ((Right (a, (l, r), s))) 35 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/CFTT/Up.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# options_ghc -Wno-orphans #-} 3 | 4 | module CFTT.Up where 5 | 6 | import Prelude (Num(..)) 7 | import qualified Prelude as P 8 | import Data.Bits 9 | 10 | import Language.Haskell.TH 11 | import Language.Haskell.TH.Syntax 12 | 13 | type Up = CodeQ 14 | 15 | data Pair a b = Pair !a !b 16 | proj1 (Pair a b) = a 17 | proj2 (Pair a b) = b 18 | 19 | instance Num a => Num (Up a) where 20 | (+) x y = [|| $$x + $$y ||] 21 | (*) x y = [|| $$x * $$y ||] 22 | abs x = [|| abs $$x ||] 23 | signum x = [|| signum $$x ||] 24 | fromInteger x = [|| fromInteger $$(liftTyped x) ||] 25 | negate x = [|| negate $$x ||] 26 | 27 | class Eq a where 28 | (==) :: Up a -> Up a -> Up P.Bool 29 | (/=) :: Up a -> Up a -> Up P.Bool 30 | (/=) x y = [|| P.not $$(x == y) ||] 31 | 32 | instance P.Eq a => Eq a where 33 | (==) x y = [|| $$x P.== $$y ||] 34 | 35 | not :: Up P.Bool -> Up P.Bool 36 | not x = [|| P.not $$x ||] 37 | 38 | tt :: Up () 39 | tt = [|| () ||] 40 | 41 | down1 :: (Up a -> Up b) -> Up (a -> b) 42 | down1 f = [|| \a -> $$(f [||a||]) ||] 43 | 44 | up1 :: Up (a -> b) -> Up a -> Up b 45 | up1 f a = [|| $$f $$a ||] 46 | 47 | class Ord a where 48 | (<) :: Up a -> Up a -> Up P.Bool 49 | (<=) :: Up a -> Up a -> Up P.Bool 50 | (>) :: Up a -> Up a -> Up P.Bool 51 | (>=) :: Up a -> Up a -> Up P.Bool 52 | 53 | instance P.Ord a => Ord a where 54 | (<) x y = [|| (P.<) $$x $$y ||] 55 | (<=) x y = [|| (P.<=) $$x $$y ||] 56 | (>) x y = [|| (P.>) $$x $$y ||] 57 | (>=) x y = [|| (P.>=) $$x $$y ||] 58 | 59 | even :: Up P.Int -> Up P.Bool 60 | even n = [|| $$n .&. 1 P.== 0 ||] 61 | 62 | odd :: Up P.Int -> Up P.Bool 63 | odd n = [|| $$n .&. 1 P.== 1 ||] 64 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/haskell-cftt.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.36.0. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: haskell-cftt 8 | version: 0.1.0.0 9 | build-type: Simple 10 | 11 | flag dump 12 | description: dump core, stg and cmm to files 13 | manual: True 14 | default: False 15 | 16 | library 17 | exposed-modules: 18 | CFTT.Examples 19 | CFTT.Gen 20 | CFTT.Improve 21 | CFTT.Join 22 | CFTT.Pull 23 | CFTT.SOP 24 | CFTT.Split 25 | CFTT.Tree 26 | CFTT.Up 27 | other-modules: 28 | Paths_haskell_cftt 29 | hs-source-dirs: 30 | ./ 31 | default-extensions: 32 | AllowAmbiguousTypes 33 | BangPatterns 34 | BlockArguments 35 | DataKinds 36 | DeriveFunctor 37 | EmptyCase 38 | FlexibleContexts 39 | FlexibleInstances 40 | FunctionalDependencies 41 | GADTs 42 | LambdaCase 43 | MultiParamTypeClasses 44 | PolyKinds 45 | RankNTypes 46 | ScopedTypeVariables 47 | StandaloneKindSignatures 48 | Strict 49 | TemplateHaskell 50 | TupleSections 51 | TypeApplications 52 | TypeFamilies 53 | TypeOperators 54 | UndecidableInstances 55 | UnicodeSyntax 56 | ViewPatterns 57 | ghc-options: -Wall -Wno-missing-signatures -Wno-name-shadowing -Wno-unused-do-bind -Wno-unused-matches -Wno-partial-type-signatures -O0 58 | build-depends: 59 | base >=4.7 && <5 60 | , mtl 61 | , template-haskell 62 | , transformers 63 | default-language: Haskell2010 64 | if flag(dump) 65 | ghc-options: -ddump-simpl -dsuppress-all -dno-suppress-type-signatures -ddump-to-file 66 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/package.yaml: -------------------------------------------------------------------------------- 1 | name: haskell-cftt 2 | version: 0.1.0.0 3 | # license: MIT 4 | # author: 5 | # maintainer: 6 | # copyright: 7 | 8 | flags: 9 | dump: 10 | description: dump core, stg and cmm to files 11 | default: false 12 | manual: true 13 | 14 | ghc-options: 15 | - -Wall 16 | - -Wno-missing-signatures 17 | - -Wno-name-shadowing 18 | - -Wno-unused-do-bind 19 | - -Wno-unused-matches 20 | - -Wno-partial-type-signatures 21 | - -O0 22 | 23 | when: 24 | - condition: flag(dump) 25 | ghc-options: 26 | - -ddump-simpl 27 | # - -ddump-stg-final 28 | # - -ddump-cmm 29 | - -dsuppress-all 30 | - -dno-suppress-type-signatures 31 | - -ddump-to-file 32 | 33 | default-extensions: 34 | - AllowAmbiguousTypes 35 | - BangPatterns 36 | - BlockArguments 37 | - DataKinds 38 | - DeriveFunctor 39 | - EmptyCase 40 | - FlexibleContexts 41 | - FlexibleInstances 42 | - FunctionalDependencies 43 | - GADTs 44 | - LambdaCase 45 | - MultiParamTypeClasses 46 | - PolyKinds 47 | - RankNTypes 48 | - ScopedTypeVariables 49 | - StandaloneKindSignatures 50 | - Strict 51 | - TemplateHaskell 52 | - TupleSections 53 | - TypeApplications 54 | - TypeFamilies 55 | - TypeOperators 56 | - UndecidableInstances 57 | - UnicodeSyntax 58 | - ViewPatterns 59 | 60 | library: 61 | source-dirs: . 62 | dependencies: 63 | - base >= 4.7 && < 5 64 | - mtl 65 | - transformers 66 | - template-haskell 67 | -------------------------------------------------------------------------------- /icfp24paper/supplement/haskell-cftt/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | # ghc 9.6.4 3 | resolver: lts-22.12 4 | 5 | packages: 6 | - . 7 | -------------------------------------------------------------------------------- /icfp24prez/abstract.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{DBLP:phd/ethos/Coutts11} 4 | Duncan Coutts. 5 | \newblock {\em Stream fusion : practical shortcut fusion for coinductive 6 | sequence types}. 7 | \newblock PhD thesis, University of Oxford, {UK}, 2011. 8 | 9 | \bibitem{DBLP:conf/pepm/0001K24} 10 | Tomoaki Kobayashi and Oleg Kiselyov. 11 | \newblock Complete stream fusion for software-defined radio. 12 | \newblock In Gabriele Keller and Meng Wang, editors, {\em Proceedings of the 13 | 2024 {ACM} {SIGPLAN} International Workshop on Partial Evaluation and Program 14 | Manipulation, {PEPM} 2024, London, UK, 16 January 2024}, pages 57--69. {ACM}, 15 | 2024. 16 | 17 | \bibitem{staged2ltt} 18 | Andr{\'{a}}s Kov{\'{a}}cs. 19 | \newblock Staged compilation with two-level type theory. 20 | \newblock {\em Proc. {ACM} Program. Lang.}, 6({ICFP}):540--569, 2022. 21 | 22 | \bibitem{DBLP:conf/pepm/YallopK19} 23 | Jeremy Yallop and Oleg Kiselyov. 24 | \newblock Generating mutually recursive definitions. 25 | \newblock In Manuel~V. Hermenegildo and Atsushi Igarashi, editors, {\em 26 | Proceedings of the 2019 {ACM} {SIGPLAN} Workshop on Partial Evaluation and 27 | Program Manipulation, PEPM@POPL 2019, Cascais, Portugal, January 14-15, 28 | 2019}, pages 75--81. {ACM}, 2019. 29 | 30 | \end{thebibliography} 31 | -------------------------------------------------------------------------------- /icfp24prez/abstract.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2022/dev/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: abstract.aux 4 | The style file: plain.bst 5 | Database file #1: references.bib 6 | Repeated entry---line 5196 of file references.bib 7 | : @phdthesis{DBLP:phd/ethos/Coutts11 8 | : , 9 | I'm skipping whatever remains of this entry 10 | You've used 4 entries, 11 | 2118 wiz_defined-function locations, 12 | 530 strings with 4975 characters, 13 | and the built_in function-call counts, 1452 in all, are: 14 | = -- 149 15 | > -- 56 16 | < -- 2 17 | + -- 20 18 | - -- 16 19 | * -- 89 20 | := -- 240 21 | add.period$ -- 14 22 | call.type$ -- 4 23 | change.case$ -- 17 24 | chr.to.int$ -- 0 25 | cite$ -- 4 26 | duplicate$ -- 62 27 | empty$ -- 120 28 | format.name$ -- 16 29 | if$ -- 316 30 | int.to.chr$ -- 0 31 | int.to.str$ -- 4 32 | missing$ -- 3 33 | newline$ -- 23 34 | num.names$ -- 12 35 | pop$ -- 19 36 | preamble$ -- 1 37 | purify$ -- 14 38 | quote$ -- 0 39 | skip$ -- 49 40 | stack$ -- 0 41 | substring$ -- 93 42 | swap$ -- 20 43 | text.length$ -- 2 44 | text.prefix$ -- 0 45 | top$ -- 0 46 | type$ -- 16 47 | warning$ -- 0 48 | while$ -- 18 49 | width$ -- 5 50 | write$ -- 48 51 | (There was 1 error message) 52 | -------------------------------------------------------------------------------- /icfp24prez/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24prez/abstract.pdf -------------------------------------------------------------------------------- /icfp24prez/pres/AndrásKovács.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24prez/pres/AndrásKovács.pdf -------------------------------------------------------------------------------- /icfp24prez/pres/Notes.hs: -------------------------------------------------------------------------------- 1 | 2 | module Notes where 3 | 4 | import Control.Monad.Reader 5 | 6 | f :: Reader Bool Int -> Mallac 7 | f = do 8 | b <- ask 9 | if b then return 10 10 | else return 20 11 | 12 | data Mallac 13 | 14 | data Foo = Foo {mallac :: Int} 15 | 16 | newtype 17 | -------------------------------------------------------------------------------- /icfp24prez/pres/newprez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24prez/pres/newprez.pdf -------------------------------------------------------------------------------- /icfp24prez/pres/newprez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24prez/pres/newprez.snm -------------------------------------------------------------------------------- /icfp24prez/pres/newprez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Compiling monads - example} 2 | 3 | \begin{Verbatim}[commandchars=\\\{\}] 4 | \BLU{f} \RBL{:} \GRN{Reader Bool Int} \BLU{f} \RBL{:} \GRN{Reader Bool Int} 5 | \BLU{f} \RBL{:=} \RED{do} \BLU{f} \RBL{:=} \RED{~}(down \RBL{$} \RED{do} 6 | b \RBL{<-} ask ==> b \RBL{<-} ask 7 | \RED{if} b \RED{then} return 10 split b \RBL{>>=} \RBL{\bsl}\RED{case} 8 | \RED{else} return 20 \GRN{MetaTrue} \RBL{->} return \RED{<}10\RED{>} 9 | \GRN{MetaFalse} \RBL{->} return \RED{<}20\RED{>}) 10 | 11 | 12 | \BLU{f} \RBL{:} \GRN{Reader Bool Int} 13 | ==> \BLU{f} \RBL{:=} \GRN{Reader} (\RBL{\bsl}b\RBL{.} \RED{case} b \RED{of} 14 | \GRN{True} \RBL{->} 10 15 | \GRN{False} \RBL{->} 20) 16 | \end{Verbatim} 17 | 18 | 19 | -------------------------------------------------------------------------------- /icfp24prez/pres/newprez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/icfp24prez/pres/newprez.xdv -------------------------------------------------------------------------------- /icfp24prez/pres/notes.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- 5 | -------------------------------------------------------------------------------- /newnotes/intensional.txt: -------------------------------------------------------------------------------- 1 | 2 | Modeling MLTT-lock in presheaves 3 | 4 | functor on base cats: 5 | F : 1 → Syn 6 | F = K ∙ 7 | 8 | precomposition: 9 | F* : Syn̂ → Set 10 | F* Γ = Γ ∘ K ∙ 11 | 12 | left adjoint: 13 | F! : Set → Syn̂ 14 | |F! X| i = ((j : |∙|) × Sub i (F j) × |X|j)/~ where (i, σ, x[δ]) ~ (j, Fδ ∘ σ, x) 15 | ≃ ((Sub i ∙) × X)/~ where (σ, x[id]) ~ (Fid ∘ σ, x) 16 | ≃ X 17 | x[f] = x 18 | 19 | i.e.: 20 | F! X = K X 21 | 22 | unit: 23 | 24 | η : X → F* (F! X) 25 | η x = x 26 | 27 | dep version of F* 28 | 29 | F* : Syn̂.Ty (F! Γ) → Set.Ty Γ 30 | (F* A) γ = |A| ∙ γ 31 | 32 | RA of F*: 33 | 34 | Fₛ : Set → Syn̂ 35 | |Fₛ X| i = Sub ∙ i → X 36 | x[f] = λ σ. x (σ ∘ f) 37 | 38 | dep version of RA of F* 39 | 40 | Fₛ : Set.Ty (F* Γ) → Syn̂.Ty Γ 41 | |Fₛ A| i γ = (σ : Sub ∙ i) → A (γ[σ]) 42 | 43 | 44 | comonad: 45 | F!F* : Syn̂ → Syn̂ 46 | F!F* Γ = K (|Γ|∙) 47 | 48 | ◻ = F!F* 49 | 50 | monad: 51 | FₛF* : Syn̂ → Syn̂ 52 | |FₛF* Γ|i = Sub ∙ i → |Γ|∙ 53 | 54 | but we have 55 | ◻ ⊣ FₛF* 56 | 57 | and we need a left adjoint & dep version to ◻ 58 | 59 | is FₛF* ⊣ ◻ ? 60 | 61 | Sub (FₛF* Γ) Δ ≃ Sub Γ (◻ Δ) 62 | 63 | lhs: 64 | f : ∀ i. (Sub ∙ i → |Γ|∙) → |Δ|i 65 | f (γ ∘ (∘σ)) = (f γ)[σ] 66 | 67 | 68 | rhs: 69 | f : ∀ i. |Γ|i → |Δ|∙ 70 | f (γ[σ]) = f γ 71 | -------------------------------------------------------------------------------- /old/efop_abstract/abstract.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{twolevel} 4 | Danil Annenkov, Paolo Capriotti, Nicolai Kraus, and Christian Sattler. 5 | \newblock Two-level type theory and applications. 6 | \newblock {\em ArXiv e-prints}, may 2019. 7 | 8 | \bibitem{kiselyov14metaocaml} 9 | Oleg Kiselyov. 10 | \newblock The design and implementation of {BER} metaocaml - system 11 | description. 12 | \newblock In Michael Codish and Eijiro Sumii, editors, {\em Functional and 13 | Logic Programming - 12th International Symposium, {FLOPS} 2014, Kanazawa, 14 | Japan, June 4-6, 2014. Proceedings}, volume 8475 of {\em Lecture Notes in 15 | Computer Science}, pages 86--102. Springer, 2014. 16 | 17 | \bibitem{hottbook} 18 | The {Univalent Foundations Program}. 19 | \newblock {\em Homotopy Type Theory: Univalent Foundations of Mathematics}. 20 | \newblock \url{https://homotopytypetheory.org/book}, Institute for Advanced 21 | Study, 2013. 22 | 23 | \end{thebibliography} 24 | -------------------------------------------------------------------------------- /old/efop_abstract/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/efop_abstract/abstract.pdf -------------------------------------------------------------------------------- /old/efop_abstract/ext_abstract.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 4 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 5 | \global\let\oldcontentsline\contentsline 6 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 7 | \global\let\oldnewlabel\newlabel 8 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 9 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 10 | \AtEndDocument{\ifx\hyper@anchor\@undefined 11 | \let\contentsline\oldcontentsline 12 | \let\newlabel\oldnewlabel 13 | \fi} 14 | \fi} 15 | \global\let\hyper@last\relax 16 | \gdef\HyperFirstAtBeginDocument#1{#1} 17 | \providecommand\HyField@AuxAddToFields[1]{} 18 | \providecommand\HyField@AuxAddToCoFields[2]{} 19 | \citation{twolevel} 20 | \citation{hottbook} 21 | \citation{kiselyov14metaocaml} 22 | \citation{abel2013normalization} 23 | \citation{bocquet2021induction} 24 | \citation{huber-thesis} 25 | \citation{bocquet2021induction} 26 | \bibcite{abel2013normalization}{1} 27 | \bibcite{twolevel}{2} 28 | \bibcite{bocquet2021induction}{3} 29 | \bibcite{huber-thesis}{4} 30 | \bibcite{kiselyov14metaocaml}{5} 31 | \bibcite{hottbook}{6} 32 | -------------------------------------------------------------------------------- /old/efop_abstract/ext_abstract.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/efop_abstract/ext_abstract.out -------------------------------------------------------------------------------- /old/efop_abstract/ext_abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/efop_abstract/ext_abstract.pdf -------------------------------------------------------------------------------- /old/efop_abstract/ext_abstract.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/efop_abstract/ext_abstract.zip -------------------------------------------------------------------------------- /old/icfp24_old/diff.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/diff.pdf -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Supplement to the paper "Closure-Free Functional Programming in a Two-Level Type Theory" 3 | 4 | This supplement consists of three separate artifacts: 5 | 6 | - `agda-cftt`: implements the paper in Agda, using a precise embedding of the 7 | object language as postulated higher-order abstract syntax. In particular, 8 | computation and value types are tracked. 9 | - `haskell-cftt`: implements the paper in typed Template Haskell. Does not 10 | track computation and value types. 11 | - `agda-opsem`: formalizes a syntax and operational semantics for the object 12 | theory and develops some basic metatheory for it. 13 | 14 | In each folder, build instructions and further documentation can be found in the 15 | local README-s and the sources files. 16 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/agda-cftt/Improve.agda: -------------------------------------------------------------------------------- 1 | 2 | module Improve where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import Split 8 | 9 | record Improve (F : VTy → Ty) (M : Set → Set) : Set₁ where 10 | field 11 | ⦃ MGM ⦄ : MonadGen M 12 | up : ∀ {A} → ↑ (F A) → M (↑V A) 13 | down : ∀ {A} → M (↑V A) → ↑ (F A) 14 | open Improve ⦃...⦄ public 15 | 16 | instance 17 | ImpIdentity : Improve Identity∘ Gen 18 | Improve.up ImpIdentity x = pure (runIdentity∘ x) 19 | Improve.down ImpIdentity x = runGen (identity∘ <$> x) 20 | 21 | ImpMaybeT : ∀ {F M} → ⦃ _ : Improve F M ⦄ → Improve (MaybeT∘ F) (MaybeT M) 22 | Improve.up ImpMaybeT x = maybeT do x ← up (runMaybeT∘ x); split x 23 | Improve.down ImpMaybeT (maybeT x) = maybeT∘ $ down do 24 | x >>= λ where 25 | nothing → pure nothing∘ 26 | (just a) → pure (just∘ a) 27 | 28 | ImpStateT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (StateT∘ S F) (StateT (↑V S) M) 29 | Improve.up ImpStateT x = stateT λ s → do as ← up (runStateT∘ x s); split as 30 | Improve.down ImpStateT (stateT x) = stateT∘ λ s → down (do (a , s) ← x s; pure (a ,∘ s)) 31 | 32 | ImpReaderT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (ReaderT∘ S F) (ReaderT (↑V S) M) 33 | Improve.up ImpReaderT x = readerT (up ∘ runReaderT∘ x) 34 | Improve.down ImpReaderT (readerT x) = readerT∘ (down ∘ x) 35 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/agda-cftt/Join.agda: -------------------------------------------------------------------------------- 1 | 2 | module Join where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import SOP 8 | 9 | -- tabulation for continuations 10 | -------------------------------------------------------------------------------- 11 | 12 | FunSOP↑ : Uₛ → Ty → Set 13 | FunSOP↑ [] R = ⊤ 14 | FunSOP↑ (A ∷ B) R = ↑C (A →PT R) × FunSOP↑ B R 15 | 16 | index : ∀ {A B} → FunSOP↑ A B → Elₛ A → ↑ B 17 | index fs (here x) = appₚₜ (fs .₁) x 18 | index fs (there x) = index (fs .₂) x 19 | 20 | tabulate : ∀ {A B} → (Elₛ A → ↑ B) → FunSOP↑ A B 21 | tabulate {[]} f = tt 22 | tabulate {A ∷ B} f = lamₚₜ (f ∘ here) , tabulate (f ∘ there) 23 | 24 | genFunSOP↑ : ∀ {A B} → FunSOP↑ A B → Gen (FunSOP↑ A B) 25 | genFunSOP↑ {[]} fs = pure tt 26 | genFunSOP↑ {A ∷ B} (f , fs) = _,_ <$> genLet f <*> genFunSOP↑ {B} fs 27 | 28 | -------------------------------------------------------------------------------- 29 | 30 | record MonadJoin (M : Set → Set) : Set₁ where 31 | field 32 | join : ∀ {A} ⦃ _ : IsSOP A ⦄ → M A → M A 33 | open MonadJoin ⦃...⦄ public 34 | 35 | instance 36 | MonadJoinGen : MonadJoin Gen 37 | MonadJoin.join MonadJoinGen ma = gen λ k → runGen do 38 | conts ← genFunSOP↑ (tabulate (k ∘ decode)) 39 | a ← ma 40 | pure (index conts (encode a)) 41 | 42 | MonadJoinMaybeT : ∀ {M}⦃ _ : MonadJoin M ⦄ → MonadJoin (MaybeT M) 43 | MonadJoin.join MonadJoinMaybeT (maybeT ma) = maybeT (join ma) 44 | 45 | MonadJoinReaderT : ∀ {R M}⦃ _ : MonadJoin M ⦄ → MonadJoin (ReaderT R M) 46 | MonadJoin.join MonadJoinReaderT (readerT ma) = readerT (join ∘ ma) 47 | 48 | MonadJoinStateT : ∀ {S M}⦃ _ : MonadJoin M ⦄ ⦃ _ : IsSOP S ⦄ → MonadJoin (StateT S M) 49 | MonadJoin.join MonadJoinStateT (stateT ma) = stateT (join ∘ ma) 50 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/agda-cftt/Split.agda: -------------------------------------------------------------------------------- 1 | 2 | module Split where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | 8 | record Split (A : VTy) : Set₁ where 9 | field 10 | SplitTo : Set 11 | splitGen : ↑V A → Gen SplitTo 12 | 13 | split : ∀ {M}⦃ _ : MonadGen M ⦄ → ↑V A → M SplitTo 14 | split a = liftGen (splitGen a) 15 | 16 | caseM : ∀ {M B}⦃ _ : MonadGen M ⦄ → ↑V A → (SplitTo → M B) → M B 17 | caseM a f = do x ← split a; f x 18 | open Split ⦃...⦄ public 19 | 20 | data SplitListTy (A : VTy) : Set where 21 | nil : SplitListTy A 22 | cons : ↑V A → ↑V (List∘ A) → SplitListTy A 23 | 24 | data SplitTreeTy (A : VTy) : Set where 25 | leaf : SplitTreeTy A 26 | node : ↑V A → ↑V (Tree∘ A) → ↑V (Tree∘ A) → SplitTreeTy A 27 | 28 | instance 29 | SplitBool : Split Bool∘ 30 | Split.SplitTo SplitBool = Bool 31 | Split.splitGen SplitBool x = gen λ k → caseBool∘ x (k true) (k false) 32 | 33 | SplitMaybe : ∀ {A} → Split (Maybe∘ A) 34 | Split.SplitTo (SplitMaybe {A}) = Maybe (↑V A) 35 | Split.splitGen SplitMaybe x = gen λ k → caseMaybe∘ x (k nothing) (λ a → k (just a)) 36 | 37 | SplitList : ∀ {A} → Split (List∘ A) 38 | Split.SplitTo (SplitList {A}) = SplitListTy A 39 | Split.splitGen (SplitList {A}) x = gen λ k → caseList∘ x (k nil) λ a as → k (cons a as) 40 | 41 | Split× : ∀ {A B} → Split (A ×∘ B) 42 | Split.SplitTo (Split× {A} {B}) = ↑V A × ↑V B 43 | Split.splitGen Split× x = gen λ k → case×∘ x λ a b → k (a , b) 44 | 45 | SplitTree : ∀ {A} → Split (Tree∘ A) 46 | Split.SplitTo (SplitTree {A}) = SplitTreeTy A 47 | Split.splitGen SplitTree x = gen λ k → caseTree∘ x (k leaf) (λ x l r → k (node x l r)) 48 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/agda-opsem/Lib.agda: -------------------------------------------------------------------------------- 1 | 2 | module Lib where 3 | 4 | open import Relation.Binary.PropositionalEquality 5 | renaming (subst to tr; sym to infix 5 _⁻¹; trans to infixr 4 _◼_; 6 | cong to ap) 7 | renaming ([_] to hide) 8 | public 9 | 10 | open import Data.Product 11 | renaming (proj₁ to ₁; proj₂ to ₂) 12 | hiding (_<*>_) 13 | public 14 | 15 | open import Data.Maybe hiding (ap; map; zip) public 16 | open import Data.Nat hiding (_+_; _*_) public 17 | open import Data.Nat.Properties public 18 | open import Data.Nat.Induction public 19 | open import Function public 20 | open import Data.Unit using (⊤; tt) public 21 | open import Data.Empty public 22 | 23 | -------------------------------------------------------------------------------- 24 | 25 | _⊗_ : 26 | ∀ {α β}{A : Set α}{B : Set β} 27 | {f g : A → B}(p : f ≡ g){a a' : A}(q : a ≡ a') 28 | → f a ≡ g a' 29 | refl ⊗ refl = refl 30 | infixl 8 _⊗_ 31 | 32 | return : ∀ {i}{A : Set i} → A → Maybe A 33 | return = just 34 | 35 | infixl 1 _>>_ 36 | _>>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe A → Maybe B → Maybe B 37 | ma >> mb = ma >>= λ _ → mb 38 | 39 | infixl 4 _<$>_ 40 | _<$>_ : ∀ {i j}{A : Set i}{B : Set j} → (A → B) → Maybe A → Maybe B 41 | f <$> ma = do 42 | a ← ma 43 | just (f a) 44 | 45 | infixl 4 _<*>_ 46 | _<*>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe (A → B) → Maybe A → Maybe B 47 | mf <*> ma = do 48 | f ← mf 49 | a ← ma 50 | just (f a) 51 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/CFTT/Improve.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Improve where 3 | 4 | import Control.Monad.Identity 5 | import Control.Monad.Except 6 | import Control.Monad.Reader 7 | import Control.Monad.State.Strict 8 | import Control.Monad.Trans.Maybe 9 | 10 | import CFTT.Up 11 | import CFTT.Gen 12 | import CFTT.Split 13 | 14 | class MonadGen n => Improve m n | m -> n, n -> m where 15 | up :: Up (m a) -> n (Up a) 16 | down :: n (Up a) -> Up (m a) 17 | 18 | instance Improve Identity Gen where 19 | up x = Gen \k -> k [||runIdentity $$x||] 20 | down x = unGen x \a -> [||Identity $$a||] 21 | 22 | instance (Improve m n) => Improve (StateT s m) (StateT (Up s) n) where 23 | 24 | up x = StateT \s -> 25 | do as <- up [|| runStateT $$x $$s ||] 26 | split as 27 | 28 | down x = [|| StateT \s -> $$(down 29 | do (a, s) <- runStateT x [||s||] 30 | pure [||($$a, $$s)||] 31 | )||] 32 | 33 | instance (Improve m n) => Improve (ExceptT e m) (ExceptT (Up e) n) where 34 | up x = ExceptT do 35 | ea <- up [||runExceptT $$x||] 36 | split ea 37 | 38 | down (ExceptT x) = 39 | [|| ExceptT $$(down (x >>= \case 40 | Left e -> pure [||Left $$e||] 41 | Right a -> pure [||Right $$a||] 42 | )) ||] 43 | 44 | instance Improve m n => Improve (MaybeT m) (MaybeT n) where 45 | up x = MaybeT do 46 | ma <- up [||runMaybeT $$x||] 47 | split ma 48 | 49 | down (MaybeT x) = 50 | [|| MaybeT $$(down (x >>= \case 51 | Nothing -> pure [||Nothing||] 52 | Just a -> pure [||Just $$a||])) ||] 53 | 54 | instance Improve m n => Improve (ReaderT r m) (ReaderT (Up r) n) where 55 | up x = ReaderT \r -> up [||runReaderT $$x $$r||] 56 | down x = [|| ReaderT \r -> $$(down (runReaderT x [||r||])) ||] 57 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/CFTT/Join.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Join where 3 | 4 | import Data.Kind 5 | import Control.Monad.Except 6 | import Control.Monad.Reader 7 | import Control.Monad.State.Strict 8 | import Control.Monad.Trans.Maybe 9 | 10 | import CFTT.Up 11 | import CFTT.Gen 12 | import CFTT.SOP 13 | 14 | -- Functions from Elₛ to Up 15 | -------------------------------------------------------------------------------- 16 | 17 | type family FunSU (a ∷ Uₛ) (b ∷ Type) ∷ Type where 18 | FunSU '[] b = () 19 | FunSU (a ': as) b = (Up (Funₚₜ a b), FunSU as b) 20 | 21 | tabulate ∷ ∀ a b. Sing a → (Elₛ a → Up b) → FunSU a b 22 | tabulate SNil f = () 23 | tabulate (SCons as ass) f = (lamₚₜ as (f . Here), tabulate ass (f . There)) 24 | 25 | index ∷ FunSU a b → Elₛ a → Up b 26 | index fs (Here x) = appₚₜ (fst fs) x 27 | index fs (There x) = index (snd fs) x 28 | 29 | genFunSU ∷ ∀ a b. Sing a → FunSU a b → Gen (FunSU a b) 30 | genFunSU SNil fs = pure () 31 | genFunSU (SCons a as) fs = (,) <$> gen (fst fs) <*> genFunSU @_ @b as (snd fs) 32 | 33 | class MonadJoin m where 34 | join :: IsSOP a => m a -> m a 35 | 36 | instance MonadJoin Gen where 37 | join ma = Gen \(k :: a -> Up r) -> runGen do 38 | let sa = singRep @a 39 | conts <- genFunSU @_ @r sa (tabulate sa (k . decode)) 40 | a <- ma 41 | pure $ index conts (encode a) 42 | 43 | instance (IsSOP e, MonadJoin m) => MonadJoin (ExceptT e m) where 44 | join (ExceptT ma) = ExceptT $ join ma 45 | 46 | instance (MonadJoin m, IsSOP s) => MonadJoin (StateT s m) where 47 | join (StateT ma) = StateT (join . ma) 48 | 49 | instance MonadJoin m => MonadJoin (MaybeT m) where 50 | join (MaybeT ma) = MaybeT $ join ma 51 | 52 | instance (MonadJoin m) => MonadJoin (ReaderT r m) where 53 | join (ReaderT ma) = ReaderT (join . ma) 54 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/CFTT/Split.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Split where 3 | 4 | import CFTT.Up 5 | import CFTT.Gen 6 | 7 | class Split a b | a -> b, b -> a where 8 | splitGen :: Up a -> Gen b 9 | 10 | split :: MonadGen m => Split a b => Up a -> m b 11 | split a = liftGen (splitGen a) 12 | 13 | caseM :: (MonadGen m) => Split a b => Up a -> (b -> m c) -> m c 14 | caseM a f = split a >>= f 15 | 16 | instance Split Bool Bool where 17 | splitGen x = Gen \k -> [|| case $$x of 18 | True -> $$(k True) 19 | _ -> $$(k False) ||] 20 | 21 | instance Split [a] (Maybe (Up a, Up [a])) where 22 | splitGen x = Gen \k -> [|| case $$x of 23 | [] -> $$(k Nothing) 24 | a:as -> $$(k (Just ([||a||], [||as||]))) ||] 25 | 26 | instance Split (a, b) (Up a, Up b) where 27 | splitGen x = Gen \k -> [|| case $$x of 28 | (a, b) -> $$(k ([||a||], [||b||])) ||] 29 | 30 | instance Split (Pair a b) (Pair (Up a) (Up b)) where 31 | splitGen x = Gen \k -> [|| case $$x of 32 | Pair a b -> $$(k (Pair [||a||] [||b||])) ||] 33 | 34 | instance Split (Either a b) (Either (Up a) (Up b)) where 35 | splitGen x = Gen \k -> [|| case $$x of 36 | Left a -> $$(k (Left [||a||])) 37 | Right b -> $$(k (Right [||b||])) ||] 38 | 39 | instance Split (Maybe a) (Maybe (Up a)) where 40 | splitGen x = Gen \k -> [|| case $$x of 41 | Nothing -> $$(k Nothing) 42 | Just a -> $$(k (Just [||a||])) ||] 43 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/CFTT/Tree.hs: -------------------------------------------------------------------------------- 1 | 2 | module CFTT.Tree where 3 | 4 | import Data.Typeable 5 | import CFTT.Up 6 | import CFTT.Gen 7 | import CFTT.Split 8 | import CFTT.Pull 9 | import CFTT.SOP 10 | 11 | data Tree a = Leaf | Node a (Tree a) (Tree a) 12 | 13 | instance Split (Tree a) (Maybe (Up a, Up (Tree a), Up (Tree a))) where 14 | splitGen x = Gen \k -> [|| case $$x of 15 | Leaf -> $$(k Nothing) 16 | Node a l r -> $$(k (Just ([||a||], [||l||], [||r||]))) ||] 17 | 18 | instance Typeable a => CasePull (Tree a) (Maybe (Up a, Up (Tree a), Up (Tree a))) where 19 | casePull x f = case (f Nothing, unravel3 (f . Just)) of 20 | (Pull @s skip seed step, Pull' @s' skip' seed' step') -> 21 | Pull @( (Either s (Up a, (Up (Tree a), Up (Tree a)), s'))) (skip || skip') 22 | (caseM x \case Nothing -> Left <$> seed 23 | Just (a, l, r) -> do s' <- seed' $ Cons a $ Cons l $ Cons r Nil 24 | pure $ Right (a, (l, r), s')) 25 | \case 26 | (Left s) -> step s >>= \case 27 | Stop -> pure Stop 28 | Skip s -> pure $ Skip ( (Left s)) 29 | Yield c s -> pure $ Yield c ( (Left s)) 30 | (Right (a, (l, r), s)) -> step' (Cons a $ Cons l $ Cons r Nil) s >>= \case 31 | Stop -> pure Stop 32 | Skip s -> pure $ Skip (Right (a, (l, r), s)) 33 | Yield c s -> pure $ Yield c ((Right (a, (l, r), s))) 34 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/CFTT/Up.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# options_ghc -Wno-orphans #-} 3 | 4 | module CFTT.Up where 5 | 6 | import Prelude (Num(..)) 7 | import qualified Prelude as P 8 | import Data.Bits 9 | 10 | import Language.Haskell.TH 11 | import Language.Haskell.TH.Syntax 12 | 13 | type Up = CodeQ 14 | 15 | data Pair a b = Pair !a !b 16 | proj1 (Pair a b) = a 17 | proj2 (Pair a b) = b 18 | 19 | instance Num a => Num (Up a) where 20 | (+) x y = [|| $$x + $$y ||] 21 | (*) x y = [|| $$x * $$y ||] 22 | abs x = [|| abs $$x ||] 23 | signum x = [|| signum $$x ||] 24 | fromInteger x = [|| fromInteger $$(liftTyped x) ||] 25 | negate x = [|| negate $$x ||] 26 | 27 | class Eq a where 28 | (==) :: Up a -> Up a -> Up P.Bool 29 | (/=) :: Up a -> Up a -> Up P.Bool 30 | (/=) x y = [|| P.not $$(x == y) ||] 31 | 32 | instance P.Eq a => Eq a where 33 | (==) x y = [|| $$x P.== $$y ||] 34 | 35 | not :: Up P.Bool -> Up P.Bool 36 | not x = [|| P.not $$x ||] 37 | 38 | tt :: Up () 39 | tt = [|| () ||] 40 | 41 | down1 :: (Up a -> Up b) -> Up (a -> b) 42 | down1 f = [|| \a -> $$(f [||a||]) ||] 43 | 44 | up1 :: Up (a -> b) -> Up a -> Up b 45 | up1 f a = [|| $$f $$a ||] 46 | 47 | class Ord a where 48 | (<) :: Up a -> Up a -> Up P.Bool 49 | (<=) :: Up a -> Up a -> Up P.Bool 50 | (>) :: Up a -> Up a -> Up P.Bool 51 | (>=) :: Up a -> Up a -> Up P.Bool 52 | 53 | instance P.Ord a => Ord a where 54 | (<) x y = [|| (P.<) $$x $$y ||] 55 | (<=) x y = [|| (P.<=) $$x $$y ||] 56 | (>) x y = [|| (P.>) $$x $$y ||] 57 | (>=) x y = [|| (P.>=) $$x $$y ||] 58 | 59 | even :: Up P.Int -> Up P.Bool 60 | even n = [|| $$n .&. 1 P.== 0 ||] 61 | 62 | odd :: Up P.Int -> Up P.Bool 63 | odd n = [|| $$n .&. 1 P.== 1 ||] 64 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/package.yaml: -------------------------------------------------------------------------------- 1 | name: haskell-cftt 2 | version: 0.1.0.0 3 | # license: MIT 4 | # author: 5 | # maintainer: 6 | # copyright: 7 | 8 | flags: 9 | dump: 10 | description: dump core, stg and cmm to files 11 | default: false 12 | manual: true 13 | 14 | ghc-options: 15 | - -Wall 16 | - -Wno-missing-signatures 17 | - -Wno-name-shadowing 18 | - -Wno-unused-do-bind 19 | - -Wno-unused-matches 20 | - -Wno-partial-type-signatures 21 | - -O0 22 | 23 | when: 24 | - condition: flag(dump) 25 | ghc-options: 26 | - -ddump-simpl 27 | # - -ddump-stg-final 28 | # - -ddump-cmm 29 | - -dsuppress-all 30 | - -dno-suppress-type-signatures 31 | - -ddump-to-file 32 | 33 | default-extensions: 34 | - AllowAmbiguousTypes 35 | - BangPatterns 36 | - BlockArguments 37 | - DataKinds 38 | - DeriveFunctor 39 | - EmptyCase 40 | - FlexibleContexts 41 | - FlexibleInstances 42 | - FunctionalDependencies 43 | - GADTs 44 | - LambdaCase 45 | - MultiParamTypeClasses 46 | - PolyKinds 47 | - RankNTypes 48 | - ScopedTypeVariables 49 | - StandaloneKindSignatures 50 | - Strict 51 | - TemplateHaskell 52 | - TupleSections 53 | - TypeApplications 54 | - TypeFamilies 55 | - TypeOperators 56 | - UndecidableInstances 57 | - UnicodeSyntax 58 | - ViewPatterns 59 | 60 | library: 61 | source-dirs: . 62 | dependencies: 63 | - base >= 4.7 && < 5 64 | - mtl 65 | - transformers 66 | - template-haskell 67 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/submission/haskell-cftt/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | # ghc 9.6.4 3 | resolver: lts-22.12 4 | 5 | packages: 6 | - . 7 | -------------------------------------------------------------------------------- /old/icfp24_old/foobar/supplement.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/foobar/supplement.zip -------------------------------------------------------------------------------- /old/icfp24_old/hs-agda/agda-ifip-no-tailcall/Improve.agda: -------------------------------------------------------------------------------- 1 | 2 | module Improve where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import Split 8 | 9 | record Improve (F : VTy → Ty) (M : Set → Set) : Set₁ where 10 | field 11 | ⦃ MGM ⦄ : MonadGen M 12 | up : ∀ {A} → ↑ (F A) → M (↑V A) 13 | down : ∀ {A} → M (↑V A) → ↑ (F A) 14 | open Improve ⦃...⦄ public 15 | 16 | instance 17 | ImpIdentity : Improve Identity∘ Gen 18 | Improve.up ImpIdentity x = pure (runIdentity∘ x) 19 | Improve.down ImpIdentity x = runGen (identity∘ <$> x) 20 | 21 | ImpMaybeT : ∀ {F M} → ⦃ _ : Improve F M ⦄ → Improve (MaybeT∘ F) (MaybeT M) 22 | Improve.up ImpMaybeT x = maybeT do x ← up (runMaybeT∘ x); split x 23 | Improve.down ImpMaybeT (maybeT x) = maybeT∘ $ down do 24 | x >>= λ where 25 | nothing → pure nothing∘ 26 | (just a) → pure (just∘ a) 27 | 28 | ImpStateT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (StateT∘ S F) (StateT (↑V S) M) 29 | Improve.up ImpStateT x = stateT λ s → do as ← up (runStateT∘ x s); split as 30 | Improve.down ImpStateT (stateT x) = stateT∘ λ s → down (do (a , s) ← x s; pure (a ,∘ s)) 31 | 32 | ImpReaderT : ∀ {F M S} → ⦃ _ : Improve F M ⦄ → Improve (ReaderT∘ S F) (ReaderT (↑V S) M) 33 | Improve.up ImpReaderT x = readerT (up ∘ runReaderT∘ x) 34 | Improve.down ImpReaderT (readerT x) = readerT∘ (down ∘ x) 35 | -------------------------------------------------------------------------------- /old/icfp24_old/hs-agda/agda-ifip-no-tailcall/Join.agda: -------------------------------------------------------------------------------- 1 | 2 | module Join where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import SOP 8 | 9 | -- tabulation for continuations 10 | -------------------------------------------------------------------------------- 11 | 12 | FunSOP↑ : Uₛ → Ty → Set 13 | FunSOP↑ [] R = ⊤ 14 | FunSOP↑ (A ∷ B) R = ↑C (A →PT R) × FunSOP↑ B R 15 | 16 | index : ∀ {A B} → FunSOP↑ A B → Elₛ A → ↑ B 17 | index fs (here x) = appₚₜ (fs .₁) x 18 | index fs (there x) = index (fs .₂) x 19 | 20 | tabulate : ∀ {A B} → (Elₛ A → ↑ B) → FunSOP↑ A B 21 | tabulate {[]} f = tt 22 | tabulate {A ∷ B} f = lamₚₜ (f ∘ here) , tabulate (f ∘ there) 23 | 24 | genFunSOP↑ : ∀ {A B} → FunSOP↑ A B → Gen (FunSOP↑ A B) 25 | genFunSOP↑ {[]} fs = pure tt 26 | genFunSOP↑ {A ∷ B} (f , fs) = _,_ <$> genLet f <*> genFunSOP↑ {B} fs 27 | 28 | -------------------------------------------------------------------------------- 29 | 30 | record MonadJoin (M : Set → Set) : Set₁ where 31 | field 32 | join : ∀ {A} ⦃ _ : IsSOP A ⦄ → M A → M A 33 | open MonadJoin ⦃...⦄ public 34 | 35 | instance 36 | MonadJoinGen : MonadJoin Gen 37 | MonadJoin.join MonadJoinGen ma = gen λ k → runGen do 38 | conts ← genFunSOP↑ (tabulate (k ∘ decode)) 39 | a ← ma 40 | pure (index conts (encode a)) 41 | 42 | MonadJoinMaybeT : ∀ {M}⦃ _ : MonadJoin M ⦄ → MonadJoin (MaybeT M) 43 | MonadJoin.join MonadJoinMaybeT (maybeT ma) = maybeT (join ma) 44 | 45 | MonadJoinReaderT : ∀ {R M}⦃ _ : MonadJoin M ⦄ → MonadJoin (ReaderT R M) 46 | MonadJoin.join MonadJoinReaderT (readerT ma) = readerT (join ∘ ma) 47 | 48 | MonadJoinStateT : ∀ {S M}⦃ _ : MonadJoin M ⦄ ⦃ _ : IsSOP S ⦄ → MonadJoin (StateT S M) 49 | MonadJoin.join MonadJoinStateT (stateT ma) = stateT (join ∘ ma) 50 | -------------------------------------------------------------------------------- /old/icfp24_old/hs-agda/agda-ifip-tailcall/Join.agda: -------------------------------------------------------------------------------- 1 | 2 | module Join where 3 | 4 | open import Lib 5 | open import Object 6 | open import Gen 7 | open import SOP 8 | 9 | -- tabulation for continuations 10 | -------------------------------------------------------------------------------- 11 | 12 | FunSOP↑ : Uₛ → Ty → Set 13 | FunSOP↑ [] R = ⊤ 14 | FunSOP↑ (A ∷ B) R = ↑C (A →PT R) × FunSOP↑ B R 15 | 16 | index : ∀ {A B} → FunSOP↑ A B → Elₛ A → ↑ B 17 | index fs (here x) = appₚₜ (fs .₁) x 18 | index fs (there x) = index (fs .₂) x 19 | 20 | tabulate : ∀ {A B} → (Elₛ A → ↑ B) → FunSOP↑ A B 21 | tabulate {[]} f = tt 22 | tabulate {A ∷ B} f = lamₚₜ (f ∘ here) , tabulate (f ∘ there) 23 | 24 | genFunSOP↑ : ∀ {A B} → FunSOP↑ A B → Gen ⊥ (FunSOP↑ A B) 25 | genFunSOP↑ {[]} fs = pure tt 26 | genFunSOP↑ {A ∷ B} (f , fs) = _,_ <$> genLet f <*> genFunSOP↑ {B} fs 27 | 28 | -------------------------------------------------------------------------------- 29 | 30 | record MonadJoin (M : Set → Set) : Set₁ where 31 | field 32 | join : ∀ {A} ⦃ _ : IsSOP A ⦄ → M A → M A 33 | open MonadJoin ⦃...⦄ public 34 | 35 | instance 36 | MonadJoinGen : ∀ {E} → MonadJoin (Gen E) 37 | MonadJoin.join MonadJoinGen ma = gen λ l r → 38 | unGen (genFunSOP↑ (tabulate (r ∘ decode))) (λ ()) λ conts → 39 | unGen ma l λ a → 40 | index conts (encode a) 41 | 42 | MonadJoinMaybeT : ∀ {M}⦃ _ : MonadJoin M ⦄ → MonadJoin (MaybeT M) 43 | MonadJoin.join MonadJoinMaybeT (maybeT ma) = maybeT (join ma) 44 | 45 | MonadJoinReaderT : ∀ {R M}⦃ _ : MonadJoin M ⦄ → MonadJoin (ReaderT R M) 46 | MonadJoin.join MonadJoinReaderT (readerT ma) = readerT (join ∘ ma) 47 | 48 | MonadJoinStateT : ∀ {S M}⦃ _ : MonadJoin M ⦄ ⦃ _ : IsSOP S ⦄ → MonadJoin (StateT S M) 49 | MonadJoin.join MonadJoinStateT (stateT ma) = stateT (join ∘ ma) 50 | -------------------------------------------------------------------------------- /old/icfp24_old/hs-agda/agda-ifip-tailcall/README.agda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/hs-agda/agda-ifip-tailcall/README.agda -------------------------------------------------------------------------------- /old/icfp24_old/hs-agda/haskell-cftt/haskell-cftt.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.36.0. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: haskell-cftt 8 | version: 0.1.0.0 9 | build-type: Simple 10 | 11 | flag dump 12 | description: dump core, stg and cmm to files 13 | manual: True 14 | default: False 15 | 16 | library 17 | exposed-modules: 18 | CFTT.Examples 19 | CFTT.Gen 20 | CFTT.Improve 21 | CFTT.Join 22 | CFTT.MonadTailCall 23 | CFTT.Pull 24 | CFTT.SOP 25 | CFTT.Split 26 | CFTT.Tree 27 | CFTT.Up 28 | other-modules: 29 | Paths_haskell_cftt 30 | hs-source-dirs: 31 | ./ 32 | default-extensions: 33 | AllowAmbiguousTypes 34 | BangPatterns 35 | BlockArguments 36 | DataKinds 37 | DeriveFunctor 38 | EmptyCase 39 | FlexibleContexts 40 | FlexibleInstances 41 | FunctionalDependencies 42 | GADTs 43 | LambdaCase 44 | MultiParamTypeClasses 45 | PolyKinds 46 | RankNTypes 47 | ScopedTypeVariables 48 | StandaloneKindSignatures 49 | Strict 50 | TemplateHaskell 51 | TupleSections 52 | TypeApplications 53 | TypeFamilies 54 | TypeOperators 55 | UndecidableInstances 56 | UnicodeSyntax 57 | ViewPatterns 58 | ghc-options: -Wall -Wno-missing-signatures -Wno-name-shadowing -Wno-unused-do-bind -Wno-unused-matches -Wno-partial-type-signatures -O0 59 | build-depends: 60 | base >=4.7 && <5 61 | , mtl 62 | , template-haskell 63 | , transformers 64 | default-language: Haskell2010 65 | if flag(dump) 66 | ghc-options: -ddump-simpl -dsuppress-all -dno-suppress-type-signatures -ddump-to-file 67 | -------------------------------------------------------------------------------- /old/icfp24_old/paper_oldsub.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/paper_oldsub.pdf -------------------------------------------------------------------------------- /old/icfp24_old/retreatprez/newprez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/retreatprez/newprez.pdf -------------------------------------------------------------------------------- /old/icfp24_old/retreatprez/newprez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/retreatprez/newprez.snm -------------------------------------------------------------------------------- /old/icfp24_old/retreatprez/newprez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Polarization \& Closure-Freedom} 2 | 3 | \emph{Computation} and \emph{value} types are tracked 4 | in the object language. 5 | \vspace{1em} 6 | 7 | There's a value type former for \emph{closures}, 8 | that we \textbf{have not yet used} in this talk. 9 | \vspace{1em} 10 | 11 | The computational function type guarantees compilation 12 | without closures, with only statically known calls! 13 | \vspace{1em} 14 | 15 | Essentially usage of closures is surprisingly rare 16 | in programming. 17 | 18 | -------------------------------------------------------------------------------- /old/icfp24_old/retreatprez/newprez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/retreatprez/newprez.xdv -------------------------------------------------------------------------------- /old/icfp24_old/types24/AndrásKovács.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/types24/AndrásKovács.pdf -------------------------------------------------------------------------------- /old/icfp24_old/types24/newprez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/2}{}{0}} 4 | \headcommand {\beamer@framepages {2}{2}} 5 | \headcommand {\slideentry {0}{0}{3}{3/3}{}{0}} 6 | \headcommand {\beamer@framepages {3}{3}} 7 | \headcommand {\slideentry {0}{0}{4}{4/5}{}{0}} 8 | \headcommand {\beamer@framepages {4}{5}} 9 | \headcommand {\slideentry {0}{0}{5}{6/6}{}{0}} 10 | \headcommand {\beamer@framepages {6}{6}} 11 | \headcommand {\slideentry {0}{0}{6}{7/7}{}{0}} 12 | \headcommand {\beamer@framepages {7}{7}} 13 | \headcommand {\slideentry {0}{0}{7}{8/8}{}{0}} 14 | \headcommand {\beamer@framepages {8}{8}} 15 | \headcommand {\slideentry {0}{0}{8}{9/9}{}{0}} 16 | \headcommand {\beamer@framepages {9}{9}} 17 | \headcommand {\slideentry {0}{0}{9}{10/12}{}{0}} 18 | \headcommand {\beamer@framepages {10}{12}} 19 | \headcommand {\slideentry {0}{0}{10}{13/13}{}{0}} 20 | \headcommand {\beamer@framepages {13}{13}} 21 | \headcommand {\slideentry {0}{0}{11}{14/14}{}{0}} 22 | \headcommand {\beamer@framepages {14}{14}} 23 | \headcommand {\slideentry {0}{0}{12}{15/15}{}{0}} 24 | \headcommand {\beamer@framepages {15}{15}} 25 | \headcommand {\slideentry {0}{0}{13}{16/16}{}{0}} 26 | \headcommand {\beamer@framepages {16}{16}} 27 | \headcommand {\slideentry {0}{0}{14}{17/17}{}{0}} 28 | \headcommand {\beamer@framepages {17}{17}} 29 | \headcommand {\slideentry {0}{0}{15}{18/18}{}{0}} 30 | \headcommand {\beamer@framepages {18}{18}} 31 | \headcommand {\beamer@partpages {1}{18}} 32 | \headcommand {\beamer@subsectionpages {1}{18}} 33 | \headcommand {\beamer@sectionpages {1}{18}} 34 | \headcommand {\beamer@documentpages {18}} 35 | \headcommand {\gdef \inserttotalframenumber {15}} 36 | -------------------------------------------------------------------------------- /old/icfp24_old/types24/newprez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/types24/newprez.pdf -------------------------------------------------------------------------------- /old/icfp24_old/types24/newprez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/types24/newprez.snm -------------------------------------------------------------------------------- /old/icfp24_old/types24/newprez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Polarization \& Closure-Freedom} 2 | 3 | How to compile this? 4 | \vspace{1em} 5 | \begin{verbatim} 6 | f : Bool → Int → Int 7 | f b = case b of True → λ x. x + 10 8 | False → λ x. x * 10 9 | \end{verbatim} 10 | And this? 11 | \begin{verbatim} 12 | f : Int → Int 13 | f x := 14 | let g y := x + y; 15 | g x + 10 16 | \end{verbatim} 17 | -------------------------------------------------------------------------------- /old/icfp24_old/types24/newprez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/icfp24_old/types24/newprez.xdv -------------------------------------------------------------------------------- /old/mono_staged/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 András Kovács 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /old/mono_staged/Test.mstt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /old/mono_staged/src/Cxt.hs: -------------------------------------------------------------------------------- 1 | 2 | module Cxt (module Cxt.Types, module Cxt.Extension) where 3 | 4 | import Cxt.Types 5 | import Cxt.Extension 6 | -------------------------------------------------------------------------------- /old/mono_staged/src/Cxt/Fields.hs: -------------------------------------------------------------------------------- 1 | 2 | module Cxt.Fields ( 3 | HasLvl(..), HasEnv(..), HasLocals(..), HasPruning(..), HasNameTable(..), HasNames(..), 4 | HasSrc(..)) where 5 | 6 | import Cxt.Types 7 | -------------------------------------------------------------------------------- /old/mono_staged/src/Cxt/Types.hs: -------------------------------------------------------------------------------- 1 | 2 | module Cxt.Types where 3 | 4 | import Lens.Micro.TH 5 | 6 | import Common 7 | import qualified Syntax as S 8 | import qualified Values as V 9 | import Data.HashMap.Strict 10 | 11 | data NameInfo 12 | = NameInfo0 Lvl V.Ty V.CV 13 | | NameInfo1 Lvl V.Ty 14 | 15 | type NameTable = HashMap RawName NameInfo 16 | 17 | data Cxt = Cxt { 18 | cxtEnv :: V.Env, 19 | cxtLvl :: Lvl, 20 | cxtLocals :: S.Locals, 21 | cxtPruning :: S.Pruning, 22 | cxtNameTable :: NameTable, 23 | cxtNames :: [Name], 24 | cxtSrc :: RawName 25 | } 26 | 27 | makeFields ''Cxt 28 | -------------------------------------------------------------------------------- /old/mono_staged/src/InCxt.hs: -------------------------------------------------------------------------------- 1 | 2 | module InCxt ( 3 | eval0, eval1 4 | , Eval.forceF0, Eval.forceFU0, Eval.forceF1, Eval.forceFU1 5 | , Eval.up, Eval.down 6 | , unifyCxt 7 | , Eval.app1, (Eval.$$), (Eval.$$$) 8 | , quote0, quote1 9 | -- , unify0, unify1 10 | , Unif.freshMeta 11 | , Unif.freshCV 12 | ) where 13 | 14 | import Common 15 | import Cxt 16 | import Syntax 17 | import Values 18 | import qualified Evaluation as Eval 19 | import qualified Unification as Unif 20 | 21 | unifyCxt :: Cxt -> Unif.Cxt 22 | unifyCxt cxt = Unif.Cxt (cxt^.lvl) (cxt^.names) 23 | {-# inline unifyCxt #-} 24 | 25 | eval0 :: Dbg => Cxt -> Tm0 -> Val0 26 | eval0 cxt t = Eval.eval0 (cxt^.env) t 27 | {-# inline eval0 #-} 28 | 29 | eval1 :: Dbg => Cxt -> Tm1 -> Val1 30 | eval1 cxt t = Eval.eval1 (cxt^.env) t 31 | {-# inline eval1 #-} 32 | 33 | quote0 :: Dbg => Cxt -> Val0 -> Tm0 34 | quote0 cxt t = Eval.quote0 (cxt^.lvl) UnfoldNone t 35 | {-# inline quote0 #-} 36 | 37 | quote1 :: Dbg => Cxt -> Val1 -> Tm1 38 | quote1 cxt t = Eval.quote1 (cxt^.lvl) UnfoldNone t 39 | {-# inline quote1 #-} 40 | 41 | -- unify0 :: Dbg => Cxt -> Val0 -> Val0 -> IO () 42 | -- unify0 cxt t t' = Unif.unify0 (unifyCxt cxt) CSRigid t t' 43 | -- {-# inline unify0 #-} 44 | 45 | -- unify1 :: Dbg => Cxt -> Val1 -> Val1 -> IO () 46 | -- unify1 cxt t t' = Unif.unify1 (unifyCxt cxt) CSRigid t t' 47 | -- {-# inline unify1 #-} 48 | -------------------------------------------------------------------------------- /old/mono_staged/src/LvlSet.hs: -------------------------------------------------------------------------------- 1 | {-| 2 | Bitset for de Bruijn levels. It's currently just a 64-bit 'Int'. We throw an 3 | error when there are more than 64 local bound variables. If and when the need 4 | for more than 64 variables arises, we can switch to 128 bit or add a new 5 | constructor for large sets. 6 | -} 7 | 8 | module LvlSet where 9 | 10 | import Data.Coerce 11 | import Data.Bits 12 | import Data.List (foldl') 13 | import Common 14 | 15 | newtype LvlSet = LvlSet Int deriving (Eq, Bits) via Int 16 | 17 | instance Semigroup LvlSet where 18 | (<>) = (.|.) 19 | {-# inline (<>) #-} 20 | 21 | instance Monoid LvlSet where 22 | mempty = LvlSet 0 23 | {-# inline mempty #-} 24 | 25 | insert :: Lvl -> LvlSet -> LvlSet 26 | insert (Lvl x) (LvlSet s) 27 | | x > 63 = error "LvlSet.insert: element out of range" 28 | | otherwise = LvlSet (unsafeShiftL 1 x .|. s) 29 | {-# inline insert #-} 30 | 31 | single :: Lvl -> LvlSet 32 | single x = insert x mempty 33 | {-# inline single #-} 34 | 35 | delete :: Lvl -> LvlSet -> LvlSet 36 | delete (Lvl x) (LvlSet s) 37 | | x > 63 = error "LvlSet.delete: element out of range" 38 | | otherwise = LvlSet (complement (unsafeShiftL 1 x) .&. s) 39 | {-# inline delete #-} 40 | 41 | member :: Lvl -> LvlSet -> Bool 42 | member (Lvl x) (LvlSet s) 43 | | x > 63 = error "LvlSet.member: element out of range" 44 | | otherwise = (unsafeShiftL 1 x .&. s) /= 0 45 | {-# inline member #-} 46 | 47 | toList :: LvlSet -> [Lvl] 48 | toList s = filter (`member` s) (coerce [0..63::Int]) 49 | {-# inline toList #-} 50 | 51 | fromList :: [Lvl] -> LvlSet 52 | fromList = foldl' (flip insert) mempty 53 | {-# inline fromList #-} 54 | 55 | instance Show LvlSet where 56 | show = show . toList 57 | -------------------------------------------------------------------------------- /old/mono_staged/src/Plans.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Static language 4 | 5 | - Dependent TT with type-in-type, Π and native records. 6 | - Decent elaboration support for record, overloaded projection. 7 | - No inductive types. 8 | - Plain non-parametrized cycle-free modules. 9 | 10 | We keep the static language very simple. Church-coded types are sufficient for a 11 | huge number of use-cases. Plans for later: 12 | 13 | - Richer static types. For something like a lexer/parser generator, or bigger 14 | EDSL compilers, we need proper data structures. 15 | - Typeclasses. 16 | 17 | ### Runtime language 18 | 19 | - Monomorphic, strict-by-default, effectful. 20 | - Closures (A ~> B) and known functions (A -> B) are distinguished. The universe of runtime types 21 | is split to 22 | - Value types: everything except known function types. 23 | - Computation types: known function types. 24 | - It is possible to eliminate from value types to computation types. This requires 25 | eventually lifting lambdas out from eliminators, e.g. `if b then λ x. x else λ x. x + 10` 26 | becomes `λ x. if b then x else x + 10`. 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /old/mono_staged/src/Syntax.hs: -------------------------------------------------------------------------------- 1 | 2 | module Syntax where 3 | 4 | import Common 5 | 6 | type Ty = Tm1 7 | 8 | data Tm0 9 | = Var0 Ix 10 | | Top0 Lvl 11 | | Let0 Name Ty Tm0 Tm0 12 | | Lam0 Name Ty Tm0 13 | | App0 Tm0 Tm0 14 | | Case Tm0 (Cases Tm0) 15 | | Down Tm1 16 | | Field0 Tm0 Name Int 17 | | RecCon0 (Fields Tm0) 18 | | Add Tm0 Tm0 19 | | Mul Tm0 Tm0 20 | | Sub Tm0 Tm0 21 | | IntLit Int 22 | | Wk10 Tm0 23 | deriving Show 24 | 25 | type CV = Tm1 26 | 27 | data Tm1 28 | = Var1 Ix 29 | | Top1 Lvl 30 | | Let1 Name Ty Tm1 Tm1 31 | | Pi Name Icit Ty Ty 32 | | Lam1 Name Icit Ty Tm1 33 | | App1 Tm1 Tm1 Icit 34 | | Fun Ty Ty CV 35 | | U0 CV 36 | | U1 37 | | Lift CV Ty 38 | | CV 39 | | Comp 40 | | Val 41 | | Up Tm0 42 | | Rec0 (Fields Ty) 43 | | Rec1 (Fields Ty) 44 | | RecCon1 (Fields Tm1) 45 | | Field1 Tm1 Name Int 46 | | TyCon Lvl 47 | | DataCon Lvl Int 48 | | AppPruning Tm1 Pruning 49 | | Wk11 Tm1 50 | | Wk01 Tm1 51 | | Meta MetaVar 52 | | Int 53 | | Irrelevant 54 | deriving Show 55 | 56 | data Locals 57 | = Empty 58 | | Define Locals Ty Tm1 59 | | Bind0 Locals Ty CV 60 | | Bind1 Locals Ty 61 | deriving Show 62 | 63 | data PruneEntry = PESkip | PEBind0 | PEBind1 Icit 64 | deriving Show 65 | 66 | type Pruning = [PruneEntry] 67 | newtype RevPruning = RevPruning Pruning 68 | deriving stock Show 69 | 70 | up :: Tm0 -> Tm1 71 | up (Down t) = t 72 | up t = Up t 73 | {-# inline up #-} 74 | 75 | down :: Tm1 -> Tm0 76 | down (Up t) = t 77 | down t = Down t 78 | {-# inline down #-} 79 | -------------------------------------------------------------------------------- /old/mono_staged/src/UnifyCxt.hs: -------------------------------------------------------------------------------- 1 | 2 | module UnifyCxt where 3 | 4 | import Lens.Micro.TH 5 | 6 | import Common 7 | import Values 8 | import Cxt.Fields 9 | 10 | data Cxt = Cxt {cxtLvl :: Lvl, cxtNames :: [Name]} 11 | deriving Show 12 | makeFields ''Cxt 13 | 14 | bind :: Name -> Cxt -> Cxt 15 | bind x (Cxt l xs) = Cxt (l + 1) (x:xs) 16 | {-# inline bind #-} 17 | 18 | topVar :: Cxt -> Val1 19 | topVar cxt = Var1 (cxt^.lvl) 20 | {-# inline topVar #-} 21 | -------------------------------------------------------------------------------- /old/mono_staged/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: nightly-2021-12-22 2 | 3 | packages: 4 | - . 5 | 6 | ghc-options: 7 | "$everything": -split-sections 8 | 9 | extra-deps: 10 | - flatparse-0.3.2.0 11 | - git: https://github.com/AndrasKovacs/dynamic-array.git 12 | commit: c6eb41ea663c7a97c479e5536a8ef39ec848bcfa 13 | - git: https://github.com/AndrasKovacs/primdata.git 14 | commit: d0234da40ffcd6aecd2fc817e5c4e07c42d4edc8 15 | - bytestring-0.11.2.0 16 | - text-1.2.5.0@sha256:791f0f6c97ed96113f17ab520cf0efe1a3a4f883a8c85910a5660567c8241c40,7895 17 | - binary-0.8.9.0@sha256:9cac9a1d86bfa3e7f75cc8bffaa256f3967ebb6d76f67a42f9679384c5c5e18a,6523 18 | -------------------------------------------------------------------------------- /old/notes/FixFusion.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# language 3 | StandaloneDeriving, DeriveFunctor, GADTs, TypeFamilies, AllowAmbiguousTypes, TypeApplications, 4 | Strict, LambdaCase, DataKinds, PolyKinds, RankNTypes, ScopedTypeVariables, BlockArguments, 5 | PartialTypeSignatures, UnicodeSyntax 6 | #-} 7 | 8 | {-# options_ghc -Wno-unused-imports #-} 9 | 10 | newtype Fix f = Fix {fold :: ∀ x. (f x → x) → x} 11 | 12 | newtype Comp f g a = Comp {unComp :: f (g a)} 13 | 14 | data ListF a b = NilF | ConsF a b deriving (Show, Functor) 15 | 16 | fuse1 :: (∀ x. (g x → x) → (f x → x)) → Fix f → Fix g 17 | fuse1 f g = Fix \con → fold g (f con) 18 | 19 | fuse2 :: (∀ x. (g x → x) → (f (a → x) → a → x)) → Fix f → a → Fix g 20 | fuse2 f g a = Fix \con → fold g (f con) a 21 | 22 | type List a = Fix (ListF a) 23 | 24 | fuse3 :: (∀ x. (g x → x) → (f (h x) → h x)) → Fix f → h (Fix g) 25 | fuse3 f g = _ 26 | 27 | rev :: List a -> List a 28 | rev as = Fix \con → 29 | fold as 30 | (\case NilF → \acc → acc 31 | ConsF a k → \acc → k (con (ConsF a acc))) 32 | (con NilF) 33 | 34 | 35 | 36 | toList :: List a -> [a] 37 | toList as = fold as \case 38 | NilF → [] 39 | ConsF a as → a : as 40 | 41 | fromList :: [a] -> List a 42 | fromList as = Fix \con -> foldr (\a x -> con (ConsF a x)) (con NilF) as 43 | 44 | instance Show a => Show (List a) where 45 | show = show . toList 46 | 47 | 48 | 49 | 50 | -- data ListF a k = NilF | ConsF a k deriving (Show, Functor) 51 | 52 | -- fold :: Functor f ⇒ (f a → a) -> Fix f → a 53 | -- fold f (Fix ff) = let go = fold f in f (go <$> ff) 54 | 55 | -- fuse1 :: (Functor f, Functor g) ⇒ (∀ x. (g x → x) → (f x → x)) → Fix f → Fix g 56 | -- fuse1 f (Fix ff) = _ 57 | -------------------------------------------------------------------------------- /old/notes/Fusion2.agda: -------------------------------------------------------------------------------- 1 | 2 | module Fusion2 where 3 | 4 | open import Data.Product 5 | open import Data.Maybe 6 | open import Function 7 | 8 | data Step (S A : Set) : Set where 9 | done : Step S A 10 | yield : A → S → Step S A 11 | 12 | record Stream (A : Set) : Set₁ where 13 | field 14 | S : Set 15 | step : S → Step S A 16 | seed : S 17 | open Stream public 18 | 19 | {-# NON_TERMINATING #-} 20 | bindNothing : ∀ {A B : Set} (as : Stream A) (f : A → Stream B) 21 | → S as → Step (S as × Maybe (∃ (S ∘ f))) B 22 | bindJust : ∀ {A B : Set} (as : Stream A) (f : A → Stream B) 23 | → S as × ∃ (S ∘ f) → Step (S as × Maybe (∃ (S ∘ f))) B 24 | bindNothing as f sa with step as sa 25 | ... | done = done 26 | ... | yield a sa' = bindJust as f (sa , a , seed (f a)) 27 | bindJust as f (sa , a , sb) with step (f a) sb 28 | ... | done = bindNothing as f sa 29 | ... | yield b sb = yield b (sa , just (a , sb)) 30 | 31 | bind : ∀ {A B} → Stream A → (A → Stream B) → Stream B 32 | S (bind as f) = S as × Maybe (∃ (S ∘ f)) 33 | step (bind as f) (s , nothing) = bindNothing as f s 34 | step (bind as f) (s , just (a , s')) = bindJust as f (s , a , s') 35 | seed (bind as f) = seed as , nothing 36 | -------------------------------------------------------------------------------- /old/notes/Fusion3.agda: -------------------------------------------------------------------------------- 1 | 2 | module Fusion3 where 3 | 4 | open import Data.Product 5 | open import Data.Maybe 6 | open import Function 7 | 8 | data Step (S A : Set) : Set where 9 | done : Step S A 10 | skip : S → Step S A 11 | yield : A → S → Step S A 12 | 13 | record Stream (A : Set) : Set₁ where 14 | field 15 | S : Set 16 | step : S → Step S A 17 | seed : S 18 | open Stream public 19 | 20 | bind : ∀ {A B} → Stream A → (A → Stream B) → Stream B 21 | S (bind as f) = S as × Maybe (∃ (S ∘ f)) 22 | seed (bind as f) = seed as , nothing 23 | step (bind as f) (s , nothing) = skip (s , nothing) 24 | step (bind as f) (s , just (a , s')) with step (f a) s' 25 | ... | done = skip (s , nothing) 26 | ... | skip s' = skip (s , just (a , s')) 27 | ... | yield b s' = yield b (s , (just (a , s'))) 28 | -------------------------------------------------------------------------------- /old/notes/GHCComp.hs: -------------------------------------------------------------------------------- 1 | {-# language MagicHash #-} 2 | 3 | module GHCComp where 4 | 5 | import GHC.Exts 6 | 7 | -- data List = Nil | Cons Int# !List 8 | 9 | -- foo :: List -> List 10 | -- foo Nil = Nil 11 | -- foo (Cons x xs) = Cons (x *# x) (foo xs) 12 | 13 | -- foo :: Int# -> Int# -> Int# -> Int# -> Int# 14 | -- foo a b c d = a *# b *# c *# d 15 | 16 | bar :: Int# -> Int# -> Int# 17 | bar a b = a *# b 18 | {-# noinline bar #-} 19 | 20 | foo :: Int# -> Int# -> Int# 21 | foo a b = a *# (bar a b) 22 | -------------------------------------------------------------------------------- /old/notes/Objects2.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Notes 4 | 5 | Note: clang seems super good at packing/unpacking code optimization! It's worth to copypaste optimized code 6 | from godbolt. 7 | 8 | 9 | ## Runtime objects and memory layout 10 | -------------------------------------------------------------------------------- /old/notes/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/notes/a.out -------------------------------------------------------------------------------- /old/notes/clobber.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern void unknown (uint64_t* inp); 8 | /* __attribute__((noinline)) uint64_t foo (){ */ 9 | /* return 0; */ 10 | /* } */ 11 | 12 | extern void unknown2 (); 13 | 14 | uint64_t foo (uint64_t* buf){ 15 | /* buf[1] = buf[0]; */ 16 | /* asm volatile("nop" : : : ); */ 17 | uint64_t foobar = *buf; 18 | unknown2(); 19 | return *buf + foobar; 20 | } 21 | -------------------------------------------------------------------------------- /old/notes/clobber.s: -------------------------------------------------------------------------------- 1 | .file "clobber.c" 2 | .text 3 | .p2align 4 4 | .globl foo 5 | .type foo, @function 6 | foo: 7 | endbr64 8 | pushq %rbp 9 | xorl %eax, %eax 10 | pushq %rbx 11 | movq %rdi, %rbx 12 | subq $8, %rsp 13 | movq (%rdi), %rbp 14 | call unknown2@PLT 15 | movq (%rbx), %rax 16 | addq $8, %rsp 17 | popq %rbx 18 | addq %rbp, %rax 19 | popq %rbp 20 | ret 21 | .size foo, .-foo 22 | .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" 23 | .section .note.GNU-stack,"",@progbits 24 | .section .note.gnu.property,"a" 25 | .align 8 26 | .long 1f - 0f 27 | .long 4f - 1f 28 | .long 5 29 | 0: 30 | .string "GNU" 31 | 1: 32 | .align 8 33 | .long 0xc0000002 34 | .long 3f - 2f 35 | 2: 36 | .long 0x3 37 | 3: 38 | .align 8 39 | 4: 40 | -------------------------------------------------------------------------------- /old/notes/elabnotes.txt: -------------------------------------------------------------------------------- 1 | 2 | Ollef: 3 | (unordered metacontext + cached meta dependencies for scoping + topo-sorting metas when needed) 4 | is better than having ordered metas + order maintenance all the time 5 | -------------------------------------------------------------------------------- /old/notes/gccnotes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/notes/gccnotes -------------------------------------------------------------------------------- /old/notes/gccnotes.s: -------------------------------------------------------------------------------- 1 | .file "gccnotes.c" 2 | .text 3 | .globl test 4 | .type test, @function 5 | test: 6 | .LFB66: 7 | .cfi_startproc 8 | pushq %rbp 9 | .cfi_def_cfa_offset 16 10 | .cfi_offset 6, -16 11 | movq %rsp, %rbp 12 | .cfi_def_cfa_register 6 13 | subq $48, %rsp 14 | leaq 15(%rsp), %rax 15 | andq $-16, %rax 16 | movq %r13, (%rax) 17 | movq $2, 8(%rax) 18 | movq %rax, %r13 19 | movq $0, 16(%rax) 20 | movq $0, 24(%rax) 21 | movl $20, %eax 22 | leave 23 | .cfi_def_cfa 7, 8 24 | ret 25 | .cfi_endproc 26 | .LFE66: 27 | .size test, .-test 28 | .section .rodata.str1.1,"aMS",@progbits,1 29 | .LC0: 30 | .string "%d\n" 31 | .text 32 | .globl main 33 | .type main, @function 34 | main: 35 | .LFB67: 36 | .cfi_startproc 37 | subq $8, %rsp 38 | .cfi_def_cfa_offset 16 39 | movl $0, %r13d 40 | movl $20, %edx 41 | movl $.LC0, %esi 42 | movl $1, %edi 43 | movl $0, %eax 44 | call __printf_chk 45 | movl $0, %eax 46 | addq $8, %rsp 47 | .cfi_def_cfa_offset 8 48 | ret 49 | .cfi_endproc 50 | .LFE67: 51 | .size main, .-main 52 | .ident "GCC: (Ubuntu 9.3.0-10ubuntu2~16.04) 9.3.0" 53 | .section .note.GNU-stack,"",@progbits 54 | -------------------------------------------------------------------------------- /old/notes/gcnotes.s: -------------------------------------------------------------------------------- 1 | .text 2 | .intel_syntax noprefix 3 | .file "gcnotes.c" 4 | .globl map # -- Begin function map 5 | .p2align 4, 0x90 6 | .type map,@function 7 | map: # @map 8 | # %bb.0: 9 | mov rax, qword ptr [r14] 10 | mov rcx, rax 11 | shr rcx, 58 12 | jne .LBB0_2 13 | # %bb.1: 14 | mov qword ptr [r13], 0 15 | mov qword ptr [r13 + 8], rbp 16 | mov qword ptr [r13 + 16], r12 17 | mov rax, r13 18 | ret 19 | .LBB0_2: 20 | sub rsp, 40 21 | movabs r14, 288230376151711744 22 | shl rax, 19 23 | sar rax, 16 24 | mov r15, qword ptr [rax] 25 | mov rax, qword ptr [rax + 8] 26 | mov qword ptr [rsp + 8], rax 27 | lea rdi, [rsp + 16] 28 | lea r8, [rsp + 8] 29 | mov rsi, rbp 30 | mov rdx, r12 31 | mov rcx, rbx 32 | call map 33 | mov rdi, qword ptr [rsp + 24] 34 | mov rsi, qword ptr [rsp + 32] 35 | lea rcx, [rdi + 16] 36 | cmp rcx, rsi 37 | jae .LBB0_3 38 | .LBB0_4: 39 | mov qword ptr [rax], r15 40 | mov rcx, qword ptr [rsp + 16] 41 | mov qword ptr [rax + 8], rcx 42 | mov rbp, rax 43 | shr rbp, 3 44 | or rbp, r14 45 | lea rdi, [rax + 16] 46 | cmp rdi, rdx 47 | jae .LBB0_5 48 | .LBB0_6: 49 | mov qword ptr [rcx], 100 50 | mov qword ptr [rcx + 8], rbp 51 | mov rax, rcx 52 | shr rax, 3 53 | or rax, r14 54 | mov qword ptr [r13], rax 55 | mov qword ptr [r13 + 8], rcx 56 | mov qword ptr [r13 + 16], rsi 57 | add rsp, 40 58 | mov rax, r13 59 | ret 60 | .LBB0_3: 61 | mov rdx, rbx 62 | call perform_gc 63 | jmp .LBB0_4 64 | .LBB0_5: 65 | mov rdi, rax 66 | mov rsi, rdx 67 | mov rdx, rbx 68 | call perform_gc 69 | mov rcx, rax 70 | mov rsi, rdx 71 | jmp .LBB0_6 72 | .Lfunc_end0: 73 | .size map, .Lfunc_end0-map 74 | # -- End function 75 | 76 | .ident "clang version 7.1.0 (tags/RELEASE_710/final)" 77 | .section ".note.GNU-stack","",@progbits 78 | -------------------------------------------------------------------------------- /old/notes/inline_asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/notes/inline_asm -------------------------------------------------------------------------------- /old/notes/inline_asm.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | register uint64_t* Hp asm("r12"); 6 | 7 | 8 | 9 | int kek(uint64_t* ptr, uint64_t x){ 10 | *ptr = x; 11 | return 0; 12 | } 13 | 14 | uint64_t foo() { 15 | 16 | register uint64_t x asm("rbx") = 0; 17 | register uint64_t y asm("rcx") = 20; 18 | 19 | asm volatile 20 | ("addq %1, %0; addq %1, %0" 21 | : "=r" (y) 22 | : "r" (x)); 23 | 24 | return x; 25 | } 26 | 27 | uint64_t bar(uint64_t x){ 28 | return x + 100; 29 | } 30 | 31 | int main(){ 32 | printf("%ld\n", foo()); 33 | } 34 | -------------------------------------------------------------------------------- /old/notes/inline_asm.s: -------------------------------------------------------------------------------- 1 | .file "inline_asm.c" 2 | .text 3 | .p2align 4 4 | .globl kek 5 | .type kek, @function 6 | kek: 7 | .LFB27: 8 | .cfi_startproc 9 | movq %rsi, (%rdi) 10 | xorl %eax, %eax 11 | ret 12 | .cfi_endproc 13 | .LFE27: 14 | .size kek, .-kek 15 | .p2align 4 16 | .globl foo 17 | .type foo, @function 18 | foo: 19 | .LFB28: 20 | .cfi_startproc 21 | pushq %rbx 22 | .cfi_def_cfa_offset 16 23 | .cfi_offset 3, -16 24 | xorl %ebx, %ebx 25 | #APP 26 | # 17 "inline_asm.c" 1 27 | addq %rbx, %rcx; addq %rbx, %rcx 28 | # 0 "" 2 29 | #NO_APP 30 | xorl %eax, %eax 31 | popq %rbx 32 | .cfi_def_cfa_offset 8 33 | ret 34 | .cfi_endproc 35 | .LFE28: 36 | .size foo, .-foo 37 | .p2align 4 38 | .globl bar 39 | .type bar, @function 40 | bar: 41 | .LFB29: 42 | .cfi_startproc 43 | leaq 100(%rdi), %rax 44 | ret 45 | .cfi_endproc 46 | .LFE29: 47 | .size bar, .-bar 48 | .section .rodata.str1.1,"aMS",@progbits,1 49 | .LC0: 50 | .string "%ld\n" 51 | .section .text.startup,"ax",@progbits 52 | .p2align 4 53 | .globl main 54 | .type main, @function 55 | main: 56 | .LFB30: 57 | .cfi_startproc 58 | pushq %rbx 59 | .cfi_def_cfa_offset 16 60 | .cfi_offset 3, -16 61 | xorl %ebx, %ebx 62 | #APP 63 | # 17 "inline_asm.c" 1 64 | addq %rbx, %rcx; addq %rbx, %rcx 65 | # 0 "" 2 66 | #NO_APP 67 | xorl %edx, %edx 68 | movl $.LC0, %esi 69 | movl $1, %edi 70 | xorl %eax, %eax 71 | call __printf_chk 72 | xorl %eax, %eax 73 | popq %rbx 74 | .cfi_def_cfa_offset 8 75 | ret 76 | .cfi_endproc 77 | .LFE30: 78 | .size main, .-main 79 | .ident "GCC: (Ubuntu 9.3.0-21ubuntu1~16.04) 9.3.0" 80 | .section .note.GNU-stack,"",@progbits 81 | -------------------------------------------------------------------------------- /old/notes/llvmnotes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/notes/llvmnotes -------------------------------------------------------------------------------- /old/notes/llvmnotes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | int64_t foo(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f, int64_t g, int64_t h, 7 | int64_t i, int64_t j, int64_t k, int64_t l, int64_t m, int64_t n, int64_t o, int64_t p){ 8 | return a * b * c * d * e * f * g * h * i * j * k * l * m * n * o * p; 9 | } 10 | 11 | /* int main(){ */ 12 | /* printf("%ld\n", foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); */ 13 | /* return 0; */ 14 | /* } */ 15 | 16 | 17 | /* int64_t foo(int64_t a, int64_t b, int64_t c, int64_t d){ */ 18 | /* return a + b + c + d; */ 19 | /* } */ 20 | 21 | /* int main(){ */ 22 | /* printf("%ld\n", foo(1, 2, 3, 4)); */ 23 | /* return 0; */ 24 | /* } */ 25 | 26 | /* int64_t fact(int64_t n){ */ 27 | /* if (n == 0){ */ 28 | /* return 1; */ 29 | /* } else { */ 30 | /* return n * fact(n - 1); */ 31 | /* } */ 32 | /* } */ 33 | 34 | int64_t fact_go(int64_t n, int64_t acc){ 35 | if (n == 0) { 36 | return acc; 37 | } else { 38 | int64_t x = n - 1; 39 | int64_t y = n * acc; 40 | int64_t res = fact_go(x, y); 41 | return res; 42 | } 43 | } 44 | 45 | 46 | /* define dso_local cc 10 i64 @fact_go(i64, i64) #0 { */ 47 | /* %cmp = icmp eq i64 %0, 0 */ 48 | /* br i1 %cmp, label %Finish, label %Rec */ 49 | /* Finish: */ 50 | /* ret i64 %1 */ 51 | /* Rec: */ 52 | /* %x = sub nsw i64 %0, 1 */ 53 | /* %y = mul nsw i64 %0, %1 */ 54 | /* %res = tail call i64 @fact_go(i64 %x, i64 %y) */ 55 | /* ret i64 %res */ 56 | /* } */ 57 | -------------------------------------------------------------------------------- /old/notes/notes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | typedef struct { 7 | uint8_t tag ; // 6 8 | uint8_t objtype ; // 3 9 | uint8_t nobjs ; // 5 10 | uint8_t nwords ; // 5 11 | uint64_t ptr ; // 45 12 | } unpacked_obj; 13 | 14 | typedef struct { 15 | uint64_t payload; 16 | } packed_obj; 17 | 18 | static inline packed_obj pack_obj(unpacked_obj obj){ 19 | packed_obj res = { 20 | (((uint64_t)obj.tag) << 58) 21 | | (((uint64_t)obj.objtype) << 55) 22 | | (((uint64_t)obj.nobjs) << 50) 23 | | (((uint64_t)obj.nwords) << 45) 24 | | obj.ptr}; 25 | return res; 26 | } 27 | 28 | static inline void* to_ptr(packed_obj obj){ 29 | return (void*)(((int64_t)(obj.payload) << 19) >> 16); 30 | } 31 | 32 | static inline uint8_t get_tag(packed_obj obj){ 33 | return (uint8_t)((obj.payload) >> 58); 34 | } 35 | 36 | static inline uint64_t compr_ptr(void* ptr){ 37 | return (((uint64_t) ptr) << 16) >> 19; 38 | } 39 | 40 | int main() { 41 | int* ptr = malloc(sizeof(int)); 42 | *ptr = 100; 43 | unpacked_obj test = {10, 0, 0, 0, compr_ptr(ptr)}; 44 | printf("%d\n", *((int*)(to_ptr(pack_obj(test))))); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /old/notes/rts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/notes/rts -------------------------------------------------------------------------------- /old/notes/sections.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | Solution for putting vars in .text: 6 | 7 | https://stackoverflow.com/questions/58455300/assembler-warning-with-gcc-warning-when-placing-data-in-text 8 | 9 | */ 10 | 11 | /* char c1 = 'a'; */ 12 | /* /\* int f1(int n) {return n + 200;} *\/ */ 13 | /* char c2 = 'b'; */ 14 | /* char c3 = 'c'; */ 15 | 16 | /* long long mynum1 __attribute__ ((section (".text#"))) = 1200000; */ 17 | /* long long mynum2 __attribute__ ((section (".text#"))) = 999999; */ 18 | 19 | typedef struct { 20 | int arity; 21 | int foobar; 22 | } myinfo; 23 | 24 | uint64_t fun1_info __attribute__ ((section (".text#"))) = 41; 25 | uint64_t fun1(uint64_t x){ 26 | return x + 100 + x; 27 | } 28 | 29 | uint64_t fun2_info __attribute__ ((section (".text#"))) = 42; 30 | uint64_t fun2(uint64_t x){ 31 | return x + 300 + x; 32 | } 33 | 34 | myinfo fun3_info __attribute__ ((section (".text#"))) = {.arity = 100, .foobar = 0}; 35 | uint64_t fun3(uint64_t x){ 36 | return x + 300 + x; 37 | } 38 | 39 | int64_t get_info_table(void* fun){ 40 | return *((int64_t*)(fun - 8)); 41 | } 42 | 43 | int main(){ 44 | printf("%ld\n", get_info_table((void*)(&fun2))); 45 | } 46 | -------------------------------------------------------------------------------- /old/notes/sections.s: -------------------------------------------------------------------------------- 1 | .file "sections.c" 2 | .intel_syntax noprefix 3 | .text 4 | .globl c1 5 | .data 6 | .type c1, @object 7 | .size c1, 1 8 | c1: 9 | .byte 97 10 | .text 11 | .globl f1 12 | .type f1, @function 13 | f1: 14 | .LFB23: 15 | .cfi_startproc 16 | lea eax, [rdi+200] 17 | ret 18 | .cfi_endproc 19 | .LFE23: 20 | .size f1, .-f1 21 | .globl c2 22 | .data 23 | .type c2, @object 24 | .size c2, 1 25 | c2: 26 | .byte 98 27 | .globl c3 28 | .type c3, @object 29 | .size c3, 1 30 | c3: 31 | .byte 99 32 | .section .rodata.str1.1,"aMS",@progbits,1 33 | .LC0: 34 | .string "%c\n" 35 | .text 36 | .globl main 37 | .type main, @function 38 | main: 39 | .LFB24: 40 | .cfi_startproc 41 | sub rsp, 8 42 | .cfi_def_cfa_offset 16 43 | movsx edx, BYTE PTR c1[rip] 44 | mov esi, OFFSET FLAT:.LC0 45 | mov edi, 1 46 | mov eax, 0 47 | call __printf_chk 48 | mov eax, 0 49 | add rsp, 8 50 | .cfi_def_cfa_offset 8 51 | ret 52 | .cfi_endproc 53 | .LFE24: 54 | .size main, .-main 55 | .ident "GCC: (Ubuntu 9.3.0-10ubuntu2~16.04) 9.3.0" 56 | .section .note.GNU-stack,"",@progbits 57 | -------------------------------------------------------------------------------- /old/notes/structret.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | typedef struct { 5 | int64_t a; 6 | int64_t b; 7 | /* int64_t c; */ 8 | /* int64_t d; */ 9 | /* int64_t e; */ 10 | } mystruct; 11 | 12 | mystruct fun(int64_t a, int64_t b, int64_t c){ 13 | mystruct res = {a * b, b * c}; 14 | return res; 15 | } 16 | -------------------------------------------------------------------------------- /old/notes/structret.ll: -------------------------------------------------------------------------------- 1 | ; ModuleID = 'structret.c' 2 | source_filename = "structret.c" 3 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4 | target triple = "x86_64-unknown-linux-gnu" 5 | 6 | 7 | ; Function Attrs: norecurse nounwind readnone uwtable 8 | define private cc 10 { i64, i64, i64 } @fun3(i64, i64, i64) local_unnamed_addr #0 { 9 | %r1 = insertvalue { i64, i64, i64 } undef, i64 %0, 0 10 | %r2 = insertvalue { i64, i64, i64 } %r1 , i64 %1, 1 11 | %r3 = insertvalue { i64, i64, i64 } %r2 , i64 %2, 2 12 | ret { i64, i64, i64 } %r3 13 | } 14 | 15 | ; Function Attrs: norecurse nounwind readnone uwtable 16 | define private cc 10 { i64, i64, i64, i64 } @fun(i64, i64, i64, i64) local_unnamed_addr #0 { 17 | %r1 = insertvalue { i64, i64, i64, i64 } undef, i64 %0, 0 18 | %r2 = insertvalue { i64, i64, i64, i64 } %r1 , i64 %1, 1 19 | %r3 = insertvalue { i64, i64, i64, i64 } %r2 , i64 %2, 2 20 | %r4 = insertvalue { i64, i64, i64, i64 } %r3 , i64 %3, 3 21 | ret { i64, i64, i64, i64 } %r4 22 | } 23 | 24 | 25 | attributes #0 = { norecurse nounwind } 26 | 27 | !llvm.module.flags = !{!0} 28 | !llvm.ident = !{!1} 29 | 30 | !0 = !{i32 1, !"wchar_size", i32 4} 31 | !1 = !{!"clang version 7.1.0 (tags/RELEASE_710/final)"} 32 | -------------------------------------------------------------------------------- /old/notes/structret.s: -------------------------------------------------------------------------------- 1 | .text 2 | .intel_syntax noprefix 3 | .file "structret.c" 4 | .p2align 4, 0x90 # -- Begin function fun3 5 | .type .Lfun3,@function 6 | .Lfun3: # @fun3 7 | # %bb.0: 8 | mov rax, r13 9 | mov rdx, rbp 10 | mov rcx, r12 11 | ret 12 | .Lfunc_end0: 13 | .size .Lfun3, .Lfunc_end0-.Lfun3 14 | # -- End function 15 | .p2align 4, 0x90 # -- Begin function fun 16 | .type .Lfun,@function 17 | .Lfun: # @fun 18 | # %bb.0: 19 | mov qword ptr [r13 + 24], r14 20 | mov qword ptr [r13 + 16], rbx 21 | mov qword ptr [r13 + 8], r12 22 | mov qword ptr [r13], rbp 23 | mov rax, r13 24 | ret 25 | .Lfunc_end1: 26 | .size .Lfun, .Lfunc_end1-.Lfun 27 | # -- End function 28 | 29 | .ident "clang version 7.1.0 (tags/RELEASE_710/final)" 30 | .section ".note.GNU-stack","",@progbits 31 | -------------------------------------------------------------------------------- /old/references/CFA_for_FP.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/CFA_for_FP.pdf -------------------------------------------------------------------------------- /old/references/Denis Bakhvalov - Performance Analysis and Tuning on Modern CPUs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/Denis Bakhvalov - Performance Analysis and Tuning on Modern CPUs.pdf -------------------------------------------------------------------------------- /old/references/Germane-Adams2020_Chapter_LiberateAbstractGarbageCollect.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/Germane-Adams2020_Chapter_LiberateAbstractGarbageCollect.pdf -------------------------------------------------------------------------------- /old/references/Hack_Sebastian.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/Hack_Sebastian.pdf -------------------------------------------------------------------------------- /old/references/a-practical-mode-system-for-recursive-definitions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/a-practical-mode-system-for-recursive-definitions.pdf -------------------------------------------------------------------------------- /old/references/generating-mutually-recursive-definitions-short-paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/generating-mutually-recursive-definitions-short-paper.pdf -------------------------------------------------------------------------------- /old/references/ilik-2013.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/ilik-2013.pdf -------------------------------------------------------------------------------- /old/references/inlining.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/inlining.pdf -------------------------------------------------------------------------------- /old/references/let-rec-insertion-without-effects-lights-or-magic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/let-rec-insertion-without-effects-lights-or-magic.pdf -------------------------------------------------------------------------------- /old/references/linear_ssa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/linear_ssa.pdf -------------------------------------------------------------------------------- /old/references/tdpe.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/tdpe.pdf -------------------------------------------------------------------------------- /old/references/thesis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/references/thesis.pdf -------------------------------------------------------------------------------- /old/tkp_prez/Notes.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# language TemplateHaskell #-} 3 | {-# options_ghc -Wno-unused-imports #-} 4 | 5 | import Language.Haskell.TH 6 | import Language.Haskell.TH.Syntax 7 | 8 | 9 | 10 | type Code' = Code IO 11 | printCode' x = ppr . unType <$> examineCode x 12 | 13 | b :: Bool 14 | b = True 15 | 16 | code :: Code' Bool 17 | code = [|| b ||] 18 | 19 | code2 :: Code' Bool 20 | code2 = if b then [|| False ||] else [|| True ||] 21 | 22 | -- x :: B 23 | -- x = 100 * 100 24 | 25 | -- f :: Int -> Code' Int 26 | -- f x = 27 | 28 | -- g :: Code' (Int -> Int) 29 | -- g = [|| \z -> $$(f x) ||] 30 | 31 | -- f :: Bool -> Code Bool 32 | -- f b = [|| b ||] 33 | -------------------------------------------------------------------------------- /old/tkp_prez/notes.mstt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/chairEC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/chairEC.pdf -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/debug.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/debug.pdf -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/easychair.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/easychair.pdf -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/epic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/epic.pdf -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/logoEC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/logoEC.pdf -------------------------------------------------------------------------------- /old/types2021/EasyChair3.5/throneEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/EasyChair3.5/throneEC.jpg -------------------------------------------------------------------------------- /old/types2021/abstract.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 4 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 5 | \global\let\oldcontentsline\contentsline 6 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 7 | \global\let\oldnewlabel\newlabel 8 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 9 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 10 | \AtEndDocument{\ifx\hyper@anchor\@undefined 11 | \let\contentsline\oldcontentsline 12 | \let\newlabel\oldnewlabel 13 | \fi} 14 | \fi} 15 | \global\let\hyper@last\relax 16 | \gdef\HyperFirstAtBeginDocument#1{#1} 17 | \providecommand\HyField@AuxAddToFields[1]{} 18 | \providecommand\HyField@AuxAddToCoFields[2]{} 19 | \citation{twolevel} 20 | \citation{twolevel} 21 | \citation{abel2013normalization} 22 | \citation{Wieczorek:2018:CFN:3176245.3167091} 23 | \citation{DBLP:journals/cl/Breitner18} 24 | \citation{levity} 25 | \citation{twolevel} 26 | \bibstyle{plain} 27 | \bibdata{references} 28 | \bibcite{abel2013normalization}{1} 29 | \bibcite{twolevel}{2} 30 | \bibcite{DBLP:journals/cl/Breitner18}{3} 31 | \bibcite{levity}{4} 32 | \bibcite{Wieczorek:2018:CFN:3176245.3167091}{5} 33 | \newlabel{LastPage}{{}{}{}{page.}{}} 34 | \xdef\lastpage@lastpage{} 35 | \xdef\lastpage@lastpageHy{} 36 | -------------------------------------------------------------------------------- /old/types2021/abstract.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{abel2013normalization} 4 | Andreas Abel. 5 | \newblock {\em Normalization by Evaluation: Dependent Types and 6 | Impredicativity}. 7 | \newblock PhD thesis, Ludwig-Maximilians-Universit{\"a}t M{\"u}nchen, 2013. 8 | \newblock Habilitation thesis. 9 | 10 | \bibitem{twolevel} 11 | Danil Annenkov, Paolo Capriotti, Nicolai Kraus, and Christian Sattler. 12 | \newblock Two-level type theory and applications. 13 | \newblock {\em ArXiv e-prints}, may 2019. 14 | 15 | \bibitem{DBLP:journals/cl/Breitner18} 16 | Joachim Breitner. 17 | \newblock Call arity. 18 | \newblock {\em Comput. Lang. Syst. Struct.}, 52:65--91, 2018. 19 | 20 | \bibitem{levity} 21 | Richard~A. Eisenberg and Simon~Peyton Jones. 22 | \newblock Levity polymorphism. 23 | \newblock In Albert Cohen and Martin~T. Vechev, editors, {\em Proceedings of 24 | the 38th {ACM} {SIGPLAN} Conference on Programming Language Design and 25 | Implementation, {PLDI} 2017, Barcelona, Spain, June 18-23, 2017}, pages 26 | 525--539. {ACM}, 2017. 27 | 28 | \bibitem{Wieczorek:2018:CFN:3176245.3167091} 29 | Pawe\l Wieczorek and Dariusz Biernacki. 30 | \newblock A {C}oq formalization of normalization by evaluation for 31 | {M}artin-{L}\"{o}f type theory. 32 | \newblock In {\em Proceedings of the 7th ACM SIGPLAN International Conference 33 | on Certified Programs and Proofs}, CPP 2018, pages 266--279, New York, NY, 34 | USA, 2018. ACM. 35 | 36 | \end{thebibliography} 37 | -------------------------------------------------------------------------------- /old/types2021/abstract.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2019/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: abstract.aux 4 | The style file: plain.bst 5 | Database file #1: references.bib 6 | You've used 5 entries, 7 | 2118 wiz_defined-function locations, 8 | 535 strings with 5056 characters, 9 | and the built_in function-call counts, 1781 in all, are: 10 | = -- 187 11 | > -- 71 12 | < -- 2 13 | + -- 28 14 | - -- 22 15 | * -- 108 16 | := -- 295 17 | add.period$ -- 18 18 | call.type$ -- 5 19 | change.case$ -- 24 20 | chr.to.int$ -- 0 21 | cite$ -- 5 22 | duplicate$ -- 76 23 | empty$ -- 137 24 | format.name$ -- 22 25 | if$ -- 384 26 | int.to.chr$ -- 0 27 | int.to.str$ -- 5 28 | missing$ -- 4 29 | newline$ -- 29 30 | num.names$ -- 12 31 | pop$ -- 23 32 | preamble$ -- 1 33 | purify$ -- 20 34 | quote$ -- 0 35 | skip$ -- 61 36 | stack$ -- 0 37 | substring$ -- 109 38 | swap$ -- 24 39 | text.length$ -- 2 40 | text.prefix$ -- 0 41 | top$ -- 0 42 | type$ -- 20 43 | warning$ -- 0 44 | while$ -- 19 45 | width$ -- 6 46 | write$ -- 62 47 | -------------------------------------------------------------------------------- /old/types2021/abstract.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/abstract.out -------------------------------------------------------------------------------- /old/types2021/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/abstract.pdf -------------------------------------------------------------------------------- /old/types2021/easychair.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/easychair.zip -------------------------------------------------------------------------------- /old/types2021/prez/AndrasKovacs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/AndrasKovacs.pdf -------------------------------------------------------------------------------- /old/types2021/prez/prez.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{ACKS19} 2 | 3 | \bibitem[ACKS19]{twolevel} 4 | Danil Annenkov, Paolo Capriotti, Nicolai Kraus, and Christian Sattler. 5 | \newblock Two-level type theory and applications. 6 | \newblock {\em ArXiv e-prints}, may 2019. 7 | 8 | \bibitem[Voe13]{voevodsky2013simple} 9 | Vladimir Voevodsky. 10 | \newblock A simple type system with two identity types. 11 | \newblock {\em Unpublished note}, 2013. 12 | 13 | \end{thebibliography} 14 | -------------------------------------------------------------------------------- /old/types2021/prez/prez.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2019/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: prez.aux 4 | The style file: alpha.bst 5 | Database file #1: references.bib 6 | You've used 2 entries, 7 | 2543 wiz_defined-function locations, 8 | 570 strings with 4720 characters, 9 | and the built_in function-call counts, 696 in all, are: 10 | = -- 64 11 | > -- 39 12 | < -- 1 13 | + -- 15 14 | - -- 14 15 | * -- 47 16 | := -- 134 17 | add.period$ -- 6 18 | call.type$ -- 2 19 | change.case$ -- 13 20 | chr.to.int$ -- 2 21 | cite$ -- 2 22 | duplicate$ -- 27 23 | empty$ -- 41 24 | format.name$ -- 17 25 | if$ -- 129 26 | int.to.chr$ -- 1 27 | int.to.str$ -- 0 28 | missing$ -- 2 29 | newline$ -- 13 30 | num.names$ -- 6 31 | pop$ -- 12 32 | preamble$ -- 1 33 | purify$ -- 15 34 | quote$ -- 0 35 | skip$ -- 23 36 | stack$ -- 0 37 | substring$ -- 15 38 | swap$ -- 2 39 | text.length$ -- 1 40 | text.prefix$ -- 1 41 | top$ -- 0 42 | type$ -- 16 43 | warning$ -- 0 44 | while$ -- 5 45 | width$ -- 4 46 | write$ -- 26 47 | -------------------------------------------------------------------------------- /old/types2021/prez/prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/9}{}{0}} 6 | \headcommand {\beamer@framepages {5}{9}} 7 | \headcommand {\slideentry {0}{0}{4}{10/15}{}{0}} 8 | \headcommand {\beamer@framepages {10}{15}} 9 | \headcommand {\slideentry {0}{0}{5}{16/16}{}{0}} 10 | \headcommand {\beamer@framepages {16}{16}} 11 | \headcommand {\slideentry {0}{0}{6}{17/17}{}{0}} 12 | \headcommand {\beamer@framepages {17}{17}} 13 | \headcommand {\slideentry {0}{0}{7}{18/18}{}{0}} 14 | \headcommand {\beamer@framepages {18}{18}} 15 | \headcommand {\slideentry {0}{0}{8}{19/20}{}{0}} 16 | \headcommand {\beamer@framepages {19}{20}} 17 | \headcommand {\slideentry {0}{0}{9}{21/21}{}{0}} 18 | \headcommand {\beamer@framepages {21}{21}} 19 | \headcommand {\slideentry {0}{0}{10}{22/24}{}{0}} 20 | \headcommand {\beamer@framepages {22}{24}} 21 | \headcommand {\slideentry {0}{0}{11}{25/28}{}{0}} 22 | \headcommand {\beamer@framepages {25}{28}} 23 | \headcommand {\slideentry {0}{0}{12}{29/29}{}{0}} 24 | \headcommand {\beamer@framepages {29}{29}} 25 | \headcommand {\slideentry {0}{0}{13}{30/34}{}{0}} 26 | \headcommand {\beamer@framepages {30}{34}} 27 | \headcommand {\slideentry {0}{0}{14}{35/35}{}{0}} 28 | \headcommand {\beamer@framepages {35}{35}} 29 | \headcommand {\slideentry {0}{0}{15}{36/36}{}{0}} 30 | \headcommand {\beamer@framepages {36}{36}} 31 | \headcommand {\beamer@partpages {1}{36}} 32 | \headcommand {\beamer@subsectionpages {1}{36}} 33 | \headcommand {\beamer@sectionpages {1}{36}} 34 | \headcommand {\beamer@documentpages {36}} 35 | \headcommand {\gdef \inserttotalframenumber {14}} 36 | -------------------------------------------------------------------------------- /old/types2021/prez/prez.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/prez.out -------------------------------------------------------------------------------- /old/types2021/prez/prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/prez.pdf -------------------------------------------------------------------------------- /old/types2021/prez/prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/prez.snm -------------------------------------------------------------------------------- /old/types2021/prez/prez.toc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/prez.toc -------------------------------------------------------------------------------- /old/types2021/prez/prez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Rules} 2 | 3 | \begin{itemize} 4 | \item $\U_0$ (object-level) and $\U_1$ (meta-level) universes, both closed 5 | under arbitrary type formers. 6 | \item Constructors and eliminators \alert{stay within} universes! 7 | \pause 8 | \item For $A : \U_0$, we have $\Code\,A : \U_1$ 9 | \pause 10 | \item Quoting: for $A : \U_0$ and $t : A$ we have $\qtm{t} : \Code\,A$ 11 | \pause 12 | \item Splicing: for $t : \Code\,A$, we have $\sim\!t : A$ 13 | \pause 14 | \item $\qtm{\sim\!t} = t$ 15 | \item $\sim\!\qtm{t} = t$ 16 | \end{itemize} 17 | \vspace{1em} 18 | \pause 19 | 20 | Staging: computing away every meta-level subterm in an object-level term. 21 | -------------------------------------------------------------------------------- /old/types2021/prez/prez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/old/types2021/prez/prez.xdv -------------------------------------------------------------------------------- /opt/ANF.agda: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- 3 | 4 | data Ty : Set where 5 | Bool : Ty 6 | _⇒_ : Ty → Ty → Ty 7 | infixr 5 _⇒_ 8 | 9 | variable 10 | A B C : Ty 11 | 12 | data Con : Set where 13 | ∙ : Con 14 | _,_ : Con → Ty → Con 15 | infixl 2 _,_ 16 | 17 | variable 18 | Γ Δ Σ : Con 19 | 20 | data Var : Con → Ty → Set where 21 | vz : Var (Γ , A) A 22 | vs : Var Γ A → Var (Γ , B) A 23 | 24 | data Tm (Γ : Con) : Ty → Set where 25 | var : Var Γ A → Tm Γ A 26 | lam : Tm (Γ , A) B → Tm Γ (A ⇒ B) 27 | app : Tm Γ (A ⇒ B) → Tm Γ A → Tm Γ B 28 | true : Tm Γ Bool 29 | false : Tm Γ Bool 30 | ite : Tm Γ Bool → Tm Γ A → Tm Γ A → Tm Γ A 31 | 32 | -------------------------------------------------------------------------------- 33 | 34 | -- data Atom (Γ : Con) : Ty → Set where 35 | -- var : Var Γ A → Atom Γ A 36 | -- true : Atom Γ Bool 37 | -- false : Atom Γ Bool 38 | 39 | -- data ANF (Γ : Con) : Ty → Set where 40 | -- letlam : ANF (Γ , A) B → ANF (Γ , A ⇒ B) C → ANF Γ C 41 | -- letcont : ANF (Γ , A) B → 42 | -- letapp : Var Γ (A ⇒ B) → Atom Γ A → ANF (Γ , A) B → ANF Γ B 43 | -------------------------------------------------------------------------------- /opt/HOASANF.hs: -------------------------------------------------------------------------------- 1 | {-# language Strict, LambdaCase, BlockArguments #-} 2 | {-# options_ghc -Wincomplete-patterns #-} 3 | 4 | type Ix = Int 5 | type Lvl = Int 6 | 7 | data Tm 8 | = Var Ix 9 | | App Tm Tm 10 | | Lam Tm 11 | | Let Tm Tm 12 | | Inl Tm 13 | | Inr Tm 14 | | Case Tm Tm Tm 15 | deriving Show 16 | 17 | data Val 18 | = VVar Lvl 19 | | VApp Val Val 20 | | VLam (Val -> Val) 21 | | VLet Val (Val -> Val) 22 | | VInl Val 23 | | VInr Val 24 | | VCase Val (Val -> Val) (Val -> Val) 25 | 26 | quote :: Lvl -> Val -> Tm 27 | quote l = \case 28 | VVar x -> Var (l - x - 1) 29 | VApp t u -> App (quote l t) (quote l u) 30 | VLam t -> Lam (quote (l + 1) (t (VVar l))) 31 | VLet t u -> Let (quote l t) (quote (l + 1) (u (VVar l))) 32 | VInl t -> Inl (quote l t) 33 | VInr t -> Inr (quote l t) 34 | VCase t u v -> let l' = l + 1; x = VVar l in 35 | Case (quote l t) (quote l' (u x)) (quote l' (v x)) 36 | 37 | anf :: [Val] -> Tm -> (Val -> Val) -> Val 38 | anf e t k = case t of 39 | Var x -> k (e !! x) 40 | App t u -> anf e t \t -> anf e u \u -> VLet (VApp t u) k 41 | Lam t -> VLet (VLam \x -> anf (x:e) t id) k 42 | Let t u -> anf e t \t -> anf (t:e) u k 43 | Inl t -> anf e t \t -> VLet (VInl t) k 44 | Inr t -> anf e t \t -> VLet (VInr t) k 45 | Case t l r -> anf e t \t -> VLet (VLam k) \join -> 46 | VCase t (\x -> anf (x:e) l (VApp join)) 47 | (\x -> anf (x:e) r (VApp join)) 48 | 49 | anf0 :: Tm -> Tm 50 | anf0 t = quote 0 $ anf [] t id 51 | -------------------------------------------------------------------------------- /opt/HOASANF2.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# language Strict, LambdaCase, BlockArguments, ViewPatterns #-} 3 | {-# options_ghc -Wincomplete-patterns #-} 4 | 5 | type Ix = Int 6 | type Lvl = Int 7 | 8 | data Tm 9 | = Var Ix 10 | | App Tm Tm 11 | | Lam Tm 12 | | Let Tm Tm 13 | | Inl Tm 14 | | Inr Tm 15 | | Case Tm Tm Tm 16 | deriving Show 17 | 18 | data Val 19 | = VVar Lvl 20 | | VApp Lvl Lvl 21 | | VLam (Lvl -> Val) 22 | | VLet Val (Lvl -> Val) 23 | | VInl Lvl 24 | | VInr Lvl 25 | | VCase Lvl (Lvl -> Val) (Lvl -> Val) 26 | 27 | quoteVar :: Lvl -> Lvl -> Tm 28 | quoteVar l x = Var (l - x - 1) 29 | 30 | quote :: Lvl -> Val -> Tm 31 | quote l = \case 32 | VVar x -> quoteVar l x 33 | VApp t u -> App (quoteVar l t) (quoteVar l u) 34 | VLam t -> Lam (quote (l + 1) (t l)) 35 | VLet t u -> Let (quote l t) (quote (l + 1) (u l)) 36 | VInl t -> Inl (quoteVar l t) 37 | VInr t -> Inr (quoteVar l t) 38 | VCase t u v -> let l' = l + 1 in 39 | Case (quoteVar l t) (quote l' (u l)) (quote l' (v l)) 40 | 41 | anf :: [Lvl] -> Tm -> (Lvl -> Val) -> Val 42 | anf e t k = case t of 43 | Var x -> k (e !! x) 44 | App t u -> anf e t \t -> anf e u \u -> VLet (VApp t u) k 45 | Lam t -> VLet (VLam \x -> anf (x:e) t VVar) k 46 | Let t u -> anf e t \t -> anf (t:e) u k 47 | Inl t -> anf e t \t -> VLet (VInl t) k 48 | Inr t -> anf e t \t -> VLet (VInr t) k 49 | Case t l r -> anf e t \t -> VLet (VLam k) \join -> 50 | VCase t (\x -> anf (x:e) l (VApp join)) 51 | (\x -> anf (x:e) r (VApp join)) 52 | 53 | anf0 :: Tm -> Tm 54 | anf0 t = quote 0 $ anf [] t VVar 55 | -------------------------------------------------------------------------------- /opt/HOASLVL.hs: -------------------------------------------------------------------------------- 1 | 2 | {-# language Strict, BlockArguments #-} 3 | {-# options_ghc -Wincomplete-patterns #-} 4 | 5 | type Lvl = Int -- de Bruijn level 6 | 7 | data Tm 8 | = Var Lvl 9 | | App Tm Tm 10 | | Lam Tm 11 | | Let Tm Tm 12 | | Inl Tm 13 | | Inr Tm 14 | | Case Tm Tm Tm 15 | deriving Show 16 | 17 | anf :: [Lvl] -> Tm -> Lvl -> (Lvl -> Lvl -> Tm) -> Tm 18 | anf e t l k = case t of 19 | Var x -> k l (e !! (length e - x - 1)) 20 | App t u -> anf e t l \t l -> anf e u l \u l -> 21 | Let (App (Var t) (Var u)) (k l (l + 1)) 22 | Lam t -> Let (Lam (anf (l:e) t (l+1) (\t _ -> Var t))) (k l (l + 1)) 23 | Let t u -> anf e t l \t l -> anf (t:e) u l k 24 | Inl t -> anf e t l \t l -> Let (Inl (Var t)) (k l (l + 1)) 25 | Inr t -> anf e t l \t l -> Let (Inr (Var t)) (k l (l + 1)) 26 | Case t u v -> anf e t l \t l -> Case (Var t) (anf (l:e) u (l + 1) k) 27 | (anf (l:e) v (l + 1) k) 28 | 29 | -- convert a closed Tm 30 | anf0 :: Tm -> Tm 31 | anf0 t = anf [] t 0 (const . Var) 32 | -------------------------------------------------------------------------------- /opt/new/agda-src-lang/Lib.agda: -------------------------------------------------------------------------------- 1 | 2 | module Lib where 3 | 4 | open import Relation.Binary.PropositionalEquality 5 | renaming (subst to tr; sym to infix 5 _⁻¹; trans to infixr 4 _◼_; 6 | cong to ap) 7 | renaming ([_] to hide) 8 | public 9 | 10 | open import Data.Product 11 | renaming (proj₁ to ₁; proj₂ to ₂) 12 | hiding (_<*>_) 13 | public 14 | 15 | open import Data.Maybe hiding (ap; map; zip; zipWith) public 16 | open import Data.Nat hiding (_+_; _*_) public 17 | open import Data.Nat.Properties public 18 | open import Data.Nat.Induction public 19 | open import Function public 20 | open import Data.Unit using (⊤; tt) public 21 | open import Data.Empty public 22 | 23 | -------------------------------------------------------------------------------- 24 | 25 | _⊗_ : 26 | ∀ {α β}{A : Set α}{B : Set β} 27 | {f g : A → B}(p : f ≡ g){a a' : A}(q : a ≡ a') 28 | → f a ≡ g a' 29 | refl ⊗ refl = refl 30 | infixl 8 _⊗_ 31 | 32 | return : ∀ {i}{A : Set i} → A → Maybe A 33 | return = just 34 | 35 | infixl 1 _>>_ 36 | _>>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe A → Maybe B → Maybe B 37 | ma >> mb = ma >>= λ _ → mb 38 | 39 | infixl 4 _<$>_ 40 | _<$>_ : ∀ {i j}{A : Set i}{B : Set j} → (A → B) → Maybe A → Maybe B 41 | f <$> ma = do 42 | a ← ma 43 | just (f a) 44 | 45 | infixl 4 _<*>_ 46 | _<*>_ : ∀ {i j}{A : Set i}{B : Set j} → Maybe (A → B) → Maybe A → Maybe B 47 | mf <*> ma = do 48 | f ← mf 49 | a ← ma 50 | just (f a) 51 | -------------------------------------------------------------------------------- /opt/new/agda-src-lang/README.agda: -------------------------------------------------------------------------------- 1 | 2 | {- 3 | Building: 4 | - I used Agda 2.8.0 (github master, but I don't actually rely on anything fancy) 5 | and standard library version 2.2 6 | 7 | Formalization of the source language. 8 | -} 9 | 10 | open import Lib 11 | open import Syntax -- typed syntax of the language 12 | open import Interpreter -- fuelled interpreter (as operational semantics) 13 | open import Renaming -- definition & properties of variable renaming 14 | open import Bisimilarity -- notion of strong bisimilarity of terms 15 | open import Bisimilarities -- an assortment of proven bisimilarities 16 | -------------------------------------------------------------------------------- /opt/new/agda-src-lang/agda-cftt-opsem.agda-lib: -------------------------------------------------------------------------------- 1 | name: agda-cftt-opsem 2 | include: . 3 | depend: standard-library-2.2 4 | flags: 5 | -------------------------------------------------------------------------------- /opt/newnotes.txt: -------------------------------------------------------------------------------- 1 | 2 | - Present polarized src language in Agda, Haskell 3 | (Agda: type system) 4 | 5 | - Present ANF translation variants (higher-level, lower-level) for LC+sums 6 | - Explain various goals of ANF representation 7 | - Low-level ANF 8 | -------------------------------------------------------------------------------- /opt/notes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/opt/notes.txt -------------------------------------------------------------------------------- /partially_static/Notes.agda: -------------------------------------------------------------------------------- 1 | 2 | module Notes where 3 | 4 | open import Relation.Binary.PropositionalEquality 5 | renaming (sym to infix 6 ⁻¹; trans to infixr 5 _◼_; subst to tr; cong to ap) 6 | open import Data.Product 7 | open import Data.Bool 8 | open import Relation.Nullary 9 | 10 | module _ (A B : Set) 11 | (A+ : A → A → A) 12 | (A-ass : ∀ x y z → A+ (A+ x y) z ≡ A+ x (A+ y z)) 13 | (B+ : B → B → B) 14 | (B-ass : ∀ x y z → B+ (B+ x y) z ≡ B+ x (B+ y z)) 15 | where 16 | 17 | choose : Bool → Set 18 | choose false = A 19 | choose true = B 20 | 21 | data AList' : Bool → Set where 22 | single : ∀ {b} → choose b → AList' b 23 | cons : ∀ {b} → choose b → AList' (not b) → AList' b 24 | 25 | AList = ∃ AList' 26 | 27 | cons' : ∀ b → choose b → AList → AList 28 | cons' false x (false , single y ) = _ , single (A+ x y) 29 | cons' false x (false , cons y ys ) = _ , cons (A+ x y) ys 30 | cons' false x (true , xs ) = _ , cons x xs 31 | cons' true x (false , xs ) = _ , cons x xs 32 | cons' true x (true , single y ) = _ , single (B+ x y) 33 | cons' true x (true , cons y ys ) = _ , cons (B+ x y) ys 34 | 35 | infixr 5 _++_ 36 | {-# TERMINATING #-} 37 | _++_ : AList → AList → AList 38 | (b , single x) ++ ys = cons' _ x ys 39 | (b , cons x xs) ++ ys = cons' _ x ((_ , xs) ++ ys) 40 | 41 | lem : ∀ b x xs ys → cons' b x (xs ++ ys) ≡ cons' b x xs ++ ys 42 | lem false x (false , single y) ys = {!!} 43 | lem false x (false , cons y ys) zs = {!!} 44 | lem false x (true , xs) ys = refl 45 | lem true x (false , xs) ys = refl 46 | lem true x (true , xs) ys = {!!} 47 | 48 | ass : ∀ xs ys zs → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) 49 | ass (b , single x) (b' , ys) (b'' , zs) = {!!} 50 | ass (b , cons x xs) (b' , ys) (b'' , zs) = {!!} 51 | -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/.gitignore: -------------------------------------------------------------------------------- 1 | acmart.cls 2 | acmart.pdf 3 | acmguide.pdf 4 | samples/sample-*.pdf 5 | *.log 6 | *.aux 7 | *.cfg 8 | *.glo 9 | *.idx 10 | *.toc 11 | *.ilg 12 | *.ind 13 | *.out 14 | *.lof 15 | *.lot 16 | *.bbl 17 | *.blg 18 | *.gls 19 | *.cut 20 | *.hd 21 | *.dvi 22 | *.ps 23 | *.thm 24 | *.tgz 25 | *.zip 26 | *.rpi 27 | *~ 28 | *.bcf 29 | *.run.xml 30 | samples/ACM-Reference-Format.bst 31 | samples/*.tex 32 | samples/*.bbx 33 | samples/*.cbx 34 | samples/*.dbx -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/acm-jdslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/paper/acmart-primary/acm-jdslogo.png -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/acmart.ins: -------------------------------------------------------------------------------- 1 | % 2 | % Doctrip file for acmart 3 | % This file is in public domain 4 | % $Id: acmart.ins,v 1.1 2015/11/23 22:42:55 boris Exp $ 5 | % 6 | \def\batchfile{acmart.ins} 7 | \input docstrip 8 | \keepsilent 9 | \showprogress 10 | 11 | 12 | \askforoverwritefalse 13 | 14 | \generate{% 15 | \file{acmart.cls}{\from{acmart.dtx}{class}} 16 | } 17 | 18 | \obeyspaces 19 | \Msg{*****************************************************}% 20 | \Msg{* Congratulations! You successfully generated the *}% 21 | \Msg{* acmart package. *}% 22 | \Msg{* *}% 23 | \Msg{* Please move the file acmart.cls to where LaTeX *}% 24 | \Msg{* files are stored in your system. The manual is *}% 25 | \Msg{* acmart.pdf. *}% 26 | \Msg{* *}% 27 | \Msg{* The package is released under LPPL *}% 28 | \Msg{* *}% 29 | \Msg{* Happy TeXing! *}% 30 | \Msg{*****************************************************}% -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/acmdatamodel.dbx: -------------------------------------------------------------------------------- 1 | % Teach biblatex about numpages field 2 | \DeclareDatamodelFields[type=field, datatype=literal]{numpages} 3 | \DeclareDatamodelEntryfields{numpages} 4 | 5 | % Teach biblatex about articleno field 6 | \DeclareDatamodelFields[type=field, datatype=literal]{articleno} 7 | \DeclareDatamodelEntryfields{articleno} 8 | 9 | % Teach biblatex about urls field 10 | \DeclareDatamodelFields[type=list, datatype=uri]{urls} 11 | \DeclareDatamodelEntryfields{urls} 12 | 13 | % Teach biblatex about school field 14 | \DeclareDatamodelFields[type=list, datatype=literal]{school} 15 | \DeclareDatamodelEntryfields[thesis]{school} 16 | 17 | \DeclareDatamodelFields[type=field, datatype=literal]{key} 18 | \DeclareDatamodelEntryfields{key} 19 | 20 | % Teach biblatex about lastaccessed field 21 | \DeclareDatamodelFields[type=field,datatype=literal]{lastaccessed} 22 | \DeclareDatamodelEntryfields{lastaccessed} 23 | 24 | % Teach biblatex about distincturl field 25 | \DeclareDatamodelFields[type=field, datatype=literal]{distinctURL} 26 | \DeclareDatamodelEntryfields{distinctURL} 27 | 28 | 29 | % 30 | % include software data model from biblatex-software 31 | % 32 | 33 | \blx@inputonce{software.dbx}{biblatex data model extension for software}{}{}{}{} 34 | -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/acmnumeric.cbx: -------------------------------------------------------------------------------- 1 | \ProvidesFile{acmnumeric.cbx}[2017-09-27 v0.1] 2 | 3 | \RequireCitationStyle{numeric} 4 | 5 | \endinput 6 | -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/samples/sample-franklin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/paper/acmart-primary/samples/sample-franklin.png -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/samples/samples.ins: -------------------------------------------------------------------------------- 1 | \def\batchfile{samples.ins} 2 | \input docstrip 3 | \keepsilent 4 | \showprogress 5 | 6 | 7 | \askforoverwritefalse 8 | 9 | \generate{% 10 | \file{sample-manuscript.tex}{\from{samples.dtx}{manuscript}} 11 | \file{sample-acmsmall.tex}{\from{samples.dtx}{acmsmall}} 12 | \file{sample-acmsmall-submission.tex}{\from{samples.dtx}{acmsmall-submission}} 13 | \file{sample-acmsmall-biblatex.tex}{\from{samples.dtx}{acmsmall-biblatex}} 14 | \file{sample-acmlarge.tex}{\from{samples.dtx}{acmlarge}} 15 | \file{sample-acmtog.tex}{\from{samples.dtx}{acmtog}} 16 | \file{sample-sigconf.tex}{\from{samples.dtx}{sigconf}} 17 | \file{sample-sigconf-biblatex.tex}{\from{samples.dtx}{sigconf-biblatex}} 18 | \file{sample-authordraft.tex}{\from{samples.dtx}{authordraft}} 19 | \file{sample-xelatex.tex}{\from{samples.dtx}{sigconf}} 20 | \file{sample-lualatex.tex}{\from{samples.dtx}{sigconf}} 21 | \file{sample-sigplan.tex}{\from{samples.dtx}{sigplan}} 22 | \file{sample-acmsmall-conf.tex}{\from{samples.dtx}{acmsmall-conf}} 23 | \file{sample-sigconf-i13n.tex}{\from{samples.dtx}{sigconf-i13n}} 24 | \file{sample-acmengage.tex}{\from{samples.dtx}{acmengage}} 25 | \file{sample-acmcp.tex}{\from{samples.dtx}{acmcp}} 26 | } 27 | 28 | -------------------------------------------------------------------------------- /partially_static/paper/acmart-primary/samples/sampleteaser.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/paper/acmart-primary/samples/sampleteaser.pdf -------------------------------------------------------------------------------- /partially_static/paper/comment.cut: -------------------------------------------------------------------------------- 1 | To Robert, for the bagels and explaining CMYK and color spaces. 2 | -------------------------------------------------------------------------------- /partially_static/paper/paper.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2022/dev/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: paper.aux 4 | The style file: ACM-Reference-Format.bst 5 | Reallocated singl_function (elt_size=4) to 100 items from 50. 6 | Reallocated singl_function (elt_size=4) to 100 items from 50. 7 | Reallocated wiz_functions (elt_size=4) to 6000 items from 3000. 8 | Database file #1: references.bib 9 | Warning--I didn't find a database entry for "TODO" 10 | Reallocated singl_function (elt_size=4) to 100 items from 50. 11 | Reallocated glb_str_ptr (elt_size=4) to 20 items from 10. 12 | Reallocated global_strs (elt_size=200001) to 20 items from 10. 13 | Reallocated glb_str_end (elt_size=4) to 20 items from 10. 14 | Reallocated singl_function (elt_size=4) to 100 items from 50. 15 | Warning--no number and no volume in twolevel 16 | Warning--page numbers missing in both pages and numpages fields in twolevel 17 | You've used 3 entries, 18 | 5981 wiz_defined-function locations, 19 | 1498 strings with 18476 characters, 20 | and the built_in function-call counts, 3693 in all, are: 21 | = -- 587 22 | > -- 87 23 | < -- 0 24 | + -- 27 25 | - -- 28 26 | * -- 238 27 | := -- 319 28 | add.period$ -- 15 29 | call.type$ -- 3 30 | change.case$ -- 20 31 | chr.to.int$ -- 3 32 | cite$ -- 5 33 | duplicate$ -- 299 34 | empty$ -- 213 35 | format.name$ -- 36 36 | if$ -- 959 37 | int.to.chr$ -- 2 38 | int.to.str$ -- 1 39 | missing$ -- 12 40 | newline$ -- 74 41 | num.names$ -- 21 42 | pop$ -- 101 43 | preamble$ -- 1 44 | purify$ -- 44 45 | quote$ -- 0 46 | skip$ -- 100 47 | stack$ -- 0 48 | substring$ -- 292 49 | swap$ -- 32 50 | text.length$ -- 0 51 | text.prefix$ -- 0 52 | top$ -- 0 53 | type$ -- 48 54 | warning$ -- 2 55 | while$ -- 19 56 | width$ -- 0 57 | write$ -- 105 58 | (There were 3 warnings) 59 | -------------------------------------------------------------------------------- /partially_static/paper/paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/paper/paper.pdf -------------------------------------------------------------------------------- /partially_static/refs/btime_improv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/btime_improv.pdf -------------------------------------------------------------------------------- /partially_static/refs/generic-partially-static-data.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/generic-partially-static-data.pdf -------------------------------------------------------------------------------- /partially_static/refs/jonesgomardsestoft-letter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/jonesgomardsestoft-letter.pdf -------------------------------------------------------------------------------- /partially_static/refs/partially-static-data-as-free-extension-of-algebras.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/partially-static-data-as-free-extension-of-algebras.pdf -------------------------------------------------------------------------------- /partially_static/refs/tagless.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/tagless.pdf -------------------------------------------------------------------------------- /partially_static/refs/thiemann2013.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/partially_static/refs/thiemann2013.pdf -------------------------------------------------------------------------------- /runtime_codegen/agda/Notes.agda: -------------------------------------------------------------------------------- 1 | 2 | module Notes where 3 | 4 | open import Lib 5 | open import Syntax 6 | open import Embedding 7 | open import Substitution 8 | 9 | -------------------------------------------------------------------------------- 10 | 11 | {- 12 | Stage 0 : no beta redexes 13 | Stage suc : all beta redexes possible 14 | 15 | Semantic values: at stage 0 everything can be neutral, including functions 16 | 17 | evaluation at stage suc: 18 | downshifting stages is possible 19 | -} 20 | -------------------------------------------------------------------------------- /runtime_codegen/agda/Syntax.agda: -------------------------------------------------------------------------------- 1 | {-# OPTIONS --without-K #-} 2 | 3 | module Syntax where 4 | open import Lib 5 | 6 | infixr 4 _⇒_ 7 | infix 5 ↑_ 8 | 9 | data Ty : Set where 10 | ι : Ty 11 | _⇒_ : Ty → Ty → Ty 12 | ↑_ : Ty → Ty 13 | 14 | data Con : Set where 15 | ∙ : Con 16 | _,_ : Con → Ty → Con 17 | 18 | data _∈_ (A : Ty) : Con → Set where 19 | vz : ∀ {Γ} → A ∈ (Γ , A) 20 | vs : ∀ {B Γ} → (v : A ∈ Γ) → A ∈ (Γ , B) 21 | 22 | infix 5 ~_ 23 | 24 | data Tm Γ : Ty → Set where 25 | var : ∀ {A} → (v : A ∈ Γ) → Tm Γ A 26 | lam : ∀ {A B} → Tm (Γ , A) B → Tm Γ (A ⇒ B) 27 | app : ∀ {A B} → (f : Tm Γ (A ⇒ B)) → (a : Tm Γ A) → Tm Γ B 28 | <_> : ∀ {A} → Tm Γ A → Tm Γ (↑ A) 29 | ~_ : ∀ {A} → Tm Γ (↑ A) → Tm Γ A 30 | -------------------------------------------------------------------------------- /runtime_codegen/notes.txt: -------------------------------------------------------------------------------- 1 | 2 | eval 0 : computes all redexes 3 | eval (suc n) : doesn't compute any redex 4 | 5 | eval γ n = 6 | 7 | eval γ 0 ~t = case eval γ 0 t of 8 | -> eval idγ (quote t) 9 | ne t -> ne ~t 10 | 11 | eval γ (suc n) ~t = 12 | case eval γ n t of 13 | -> t 14 | ne t -> ne ~t 15 | 16 | -- eta-long ⇑A? 17 | ⇑ quotiented by η? 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | xx 27 | -------------------------------------------------------------------------------- /runtime_codegen/proto/README.md: -------------------------------------------------------------------------------- 1 | 2 | #### runtime-codegen 3 | 4 | Runtime code generation in type theory. WIP. Features: 5 | 6 | - Full type safety. 7 | - Handles open code without any modalities. 8 | - No intensional analysis. 9 | -------------------------------------------------------------------------------- /runtime_codegen/proto/mltt-runtime-codegen.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.36.0. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: mltt-runtime-codegen 8 | version: 0.1.0.0 9 | description: Runtime code generation + dependent types 10 | category: Language 11 | homepage: https://github.com/AndrasKovacs/elaboration-zoo#readme 12 | bug-reports: https://github.com/AndrasKovacs/elaboration-zoo/issues 13 | author: András Kovács 14 | maintainer: puttamalac@gmail.com 15 | copyright: 2022 András Kovács 16 | license: BSD3 17 | build-type: Simple 18 | 19 | source-repository head 20 | type: git 21 | location: https://github.com/AndrasKovacs/elaboration-zoo 22 | 23 | executable mltt-runtime-codegen 24 | main-is: Main.hs 25 | other-modules: 26 | Paths_mltt_runtime_codegen 27 | hs-source-dirs: 28 | ./ 29 | ghc-options: -O1 30 | build-depends: 31 | base >=4.7 && <5 32 | , containers 33 | , megaparsec 34 | , mtl 35 | default-language: Haskell2010 36 | -------------------------------------------------------------------------------- /runtime_codegen/proto/package.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: mltt-runtime-codegen 3 | version: 0.1.0.0 4 | github: "AndrasKovacs/elaboration-zoo" 5 | license: BSD3 6 | author: "András Kovács" 7 | maintainer: "puttamalac@gmail.com" 8 | copyright: "2022 András Kovács" 9 | category: Language 10 | 11 | description: "Runtime code generation + dependent types" 12 | 13 | dependencies: 14 | - base >= 4.7 && < 5 15 | - containers 16 | - mtl 17 | - megaparsec 18 | 19 | source-dirs: . 20 | 21 | executable: 22 | main: Main.hs 23 | ghc-options: 24 | - -O1 25 | -------------------------------------------------------------------------------- /runtime_codegen/proto/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | resolver: lts-22.9 3 | 4 | ghc-options: 5 | "$everything": -split-sections 6 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/Cxt/Type.hs: -------------------------------------------------------------------------------- 1 | 2 | module Cxt.Type where 3 | 4 | import qualified Data.Map as M 5 | 6 | import Common 7 | import Syntax 8 | import Value 9 | 10 | data Cxt = Cxt { -- Used for: 11 | env :: Env -- evaluation 12 | , lvl :: Lvl -- going under binders 13 | , locals :: Locals -- getting types of fresh metas 14 | , pruning :: Pruning -- getting terms of fresh metas (mask of bound variables) 15 | , topNames :: M.Map Name (Lvl, VTy) -- only contains info relevant to raw name lookup 16 | , localNames :: M.Map Name (Lvl, VTy) -- only contains info relevant to raw name lookup 17 | , pos :: SourcePos 18 | } 19 | 20 | names :: Cxt -> [Name] 21 | names = go . locals where 22 | go LHere = [] 23 | go (LDefine ls x _ _) = go ls :> x 24 | go (LBind ls x _) = go ls :> x 25 | 26 | instance Show Cxt where 27 | show = show . names 28 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/Notes.agda: -------------------------------------------------------------------------------- 1 | {-# OPTIONS --type-in-type #-} 2 | 3 | open import Relation.Binary.PropositionalEquality 4 | open import Data.Nat 5 | open import Data.Unit 6 | 7 | record Pair (A B : Set) : Set where 8 | constructor _,_ 9 | field 10 | fst : A 11 | snd : B 12 | open Pair 13 | 14 | ℕElim : {P : ℕ → Set} → (∀ {n} → P n → P (suc n)) → P 0 → ∀ n → P n 15 | ℕElim s z zero = z 16 | ℕElim {P} s z (suc n) = s {n} (ℕElim {P} s z n) 17 | 18 | Vec : ℕ → Set → Set 19 | Vec n A = ℕElim (λ B → Pair A B) ⊤ n 20 | 21 | vnil : ∀ {A} → Vec 0 A 22 | vnil = tt 23 | 24 | vcons : ∀ {n A} → A → Vec n A → Vec (suc n) A 25 | vcons a as = a , as 26 | 27 | caseℕ : ∀ {A : Set} → ℕ → (ℕ → A) → A → A 28 | caseℕ zero s z = z 29 | caseℕ (suc n) s z = s n 30 | 31 | test : ℕ → ℕ 32 | test x = 33 | let m : ℕ 34 | m = _ 35 | p : (caseℕ x (λ _ → 0) 0) ≡ (caseℕ m (λ _ → 0) 0) 36 | p = refl 37 | in x 38 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/README.md: -------------------------------------------------------------------------------- 1 | # rtcg 2 | 3 | Runtime code generation with dependent types. Planned features: 4 | 5 | - Type-in-type, dependent functions, Agda-style implicits and inference. 6 | - Runtime code generation. 7 | - Full scope and type safety. 8 | - Cross-stage persistence for all types. 9 | - A monad with basic IO and mutable references. 10 | - A Haskell reference interpreter. 11 | - A javascript backend using native JIT. 12 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/StringBuilder.hs: -------------------------------------------------------------------------------- 1 | 2 | module StringBuilder where 3 | 4 | import Data.String 5 | 6 | data Build = Chunk String | Append Build Build | Newline Int | Empty 7 | 8 | instance IsString Build where fromString = Chunk 9 | instance Semigroup Build where (<>) = Append 10 | instance Monoid Build where mempty = Empty 11 | 12 | newtype Out = Out (Int -> Build) 13 | deriving (Semigroup, Monoid) via (Int -> Build) 14 | 15 | str :: String -> Out 16 | str = fromString 17 | 18 | strLit :: String -> Out 19 | strLit s = "`" <> str s <> "`" 20 | 21 | instance IsString Out where fromString s = Out (\_ -> Chunk s) 22 | 23 | instance Show Out where show = build 24 | 25 | indent :: Out -> Out 26 | indent (Out f) = Out (\i -> f $! i + 4) 27 | 28 | newl :: Out 29 | newl = Out Newline 30 | 31 | build :: Out -> String 32 | build (Out f) = go (f 0) "" where 33 | go :: Build -> String -> String 34 | go b acc = case b of 35 | Chunk s -> s ++ acc 36 | Append b1 b2 -> go b1 (go b2 acc) 37 | Newline i -> let acc' = indent i acc in '\n':acc' 38 | Empty -> acc 39 | 40 | indent :: Int -> String -> String 41 | indent 0 acc = acc 42 | indent i acc = indent (i - 1) (' ':acc) 43 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/TODO.txt: -------------------------------------------------------------------------------- 1 | 2 | - Builtins: 3 | - Printing any object to terminal (best effort) 4 | - Printing concrete string to terminal 5 | 6 | - Interaction 7 | - Print 2 more lines from original src for codegen message 8 | 9 | - JS RTS: 10 | 11 | - Compilation: 12 | - more erasure in Zonk: pass/compute type, immediately erase things with U/Unit type 13 | 14 | - Elaboration 15 | - definitional monad laws 16 | - more Code unification 17 | - (record unification) 18 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/debug.rtcg: -------------------------------------------------------------------------------- 1 | 2 | Vec (n : ℕ) A : U = 3 | ℕElim (λ B. Σ(fst : A, snd : B)) Σ() n; 4 | 5 | foldr {A : U} 6 | (B : ℕ → U) 7 | (f : {n} → □ (Vec (suc n) A) → □ A → □ (B n) → □ (B (suc n))) 8 | (z : □ (B 0)) 9 | {n : ℕ} 10 | (as : □ (Vec n A)) 11 | : □ (B n) 12 | = < ℕElim 13 | {λ n. Vec n A → B n} 14 | (λ {n} rec as. ~(f )) 15 | (λ _. ~z) 16 | n ~as 17 | >; 18 | 19 | down : {A n} → Vec n (□ A) → □ (Vec n A) = 20 | ~<λ {A} {n} as. ~(foldr (λ n. □ (Vec n A)) 21 | (λ _ a res. <<~~a, ~~res>>) 22 | <<()>> 23 | ) 24 | >; 25 | 26 | -------------------------------------------------------------------------------- 27 | 28 | return () 29 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "proto2", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "readline-sync": "^1.4.10" 9 | } 10 | }, 11 | "node_modules/readline-sync": { 12 | "version": "1.4.10", 13 | "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", 14 | "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", 15 | "engines": { 16 | "node": ">= 0.8.0" 17 | } 18 | } 19 | }, 20 | "dependencies": { 21 | "readline-sync": { 22 | "version": "1.4.10", 23 | "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", 24 | "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "readline-sync": "^1.4.10" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/package.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: rtcg 3 | version: 0.1.0.0 4 | # github: "AndrasKovacs/elaboration-zoo" 5 | license: BSD3 6 | author: "András Kovács" 7 | maintainer: "puttamalac@gmail.com" 8 | copyright: "2024 András Kovács" 9 | category: Language 10 | 11 | description: "Dependently typed language supporting runtime code generation" 12 | 13 | default-extensions: 14 | - BangPatterns 15 | - BlockArguments 16 | - ConstraintKinds 17 | - DeriveAnyClass 18 | - DerivingVia 19 | - EmptyCase 20 | - EmptyDataDeriving 21 | - FunctionalDependencies 22 | - FlexibleContexts 23 | - FlexibleInstances 24 | - GADTs 25 | - GeneralizedNewtypeDeriving 26 | - ImplicitParams 27 | - LambdaCase 28 | - MultiParamTypeClasses 29 | - OverloadedStrings 30 | - PatternSynonyms 31 | - RankNTypes 32 | - ScopedTypeVariables 33 | - StandaloneDeriving 34 | - StandaloneKindSignatures 35 | - Strict 36 | - TemplateHaskell 37 | - TupleSections 38 | - ViewPatterns 39 | 40 | ghc-options: 41 | - -Wall 42 | - -Wno-name-shadowing 43 | - -Wno-missing-signatures 44 | - -Wno-unused-do-bind 45 | - -Wno-unused-matches 46 | - -Wno-missing-pattern-synonym-signatures 47 | 48 | dependencies: 49 | - base >= 4.7 && < 5 50 | - containers 51 | - directory 52 | - filepath 53 | - megaparsec 54 | - microlens-platform 55 | - mtl 56 | - process 57 | 58 | data-files: 59 | - rts.js 60 | 61 | source-dirs: . 62 | 63 | executable: 64 | main: Main.hs 65 | ghc-options: 66 | - -O 67 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/stack.yaml: -------------------------------------------------------------------------------- 1 | 2 | resolver: lts-22.31 3 | -------------------------------------------------------------------------------- /runtime_codegen/proto2/test1.rtcg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -- Gen : U → U 4 | -- = λ A. {R : U} → (A → □ R) → □ R; 5 | 6 | -- ret : {A} → A → Gen A 7 | -- = λ a k. k a; 8 | 9 | -- bind : {A B} → Gen A → (A → Gen B) → Gen B 10 | -- = λ ga f k. ga λ a. (f a) k; 11 | 12 | -- runGen : {A} → Gen (□ A) → □ A 13 | -- = λ ga. ga (λ x. x); 14 | 15 | -- ℕ : U = (N : U) → (N → N) → N → N; 16 | 17 | -- id : □ (ℕ → ℕ) = <λ x. x>; 18 | -- id2 : □ (ℕ → ℕ) = <λ x. ~(let y = ~id x; )>; 19 | 20 | iterate {A}(n : ℕ) (f : A → A) (a : A) : A = 21 | ℕElim f a n; 22 | 23 | add (n m : ℕ) = iterate n suc m; 24 | mul (n m : ℕ) = iterate m (add n) 0; 25 | 26 | n0 = zero; 27 | n1 = suc zero; 28 | n2 = suc $ suc zero; 29 | n3 = suc $ suc $ suc zero; 30 | n5 = suc $ suc $ suc $ suc $ suc zero; 31 | n10 = add n5 n5; 32 | n100 = mul n10 n10; 33 | n1k = mul n100 n10; 34 | n10k = mul n100 n100; 35 | 36 | return n1k 37 | 38 | -- mkExp : ℕ → □ (ℕ → ℕ) 39 | -- = λ x. <λ y. ~(x _ (λ f. ) )>; 40 | 41 | -- -- exp5 = ~(mkExp n5); 42 | -- return <λ (x : ℕ). suc x> 43 | 44 | 45 | -- let List : U → U = 46 | -- λ A. (L : U) → (A → L → L) → L → L; 47 | 48 | -- let nil : {A} → List A = 49 | -- λ L c n. n; 50 | 51 | -- let cons : {A} → A → List A → List A = 52 | -- λ a as L c n. c a (as L c n); 53 | 54 | -- do ref ← new (nil {⊤}); 55 | 56 | -- let id : {A} → □ A → □ A = 57 | -- λ x. x; 58 | 59 | -- let majom : Eff (⊤ → ⊤) = 60 | -- do x ← return (λ (y : ⊤). y); 61 | -- let kek = 62 | -- let bar = 63 | -- (λ (y : ⊤). y); 64 | -- bar; 65 | -- return kek; 66 | 67 | -- return id 68 | 69 | -- return (cons tt (cons tt (cons tt nil))) 70 | -------------------------------------------------------------------------------- /tkp22prez/andras_kovacs_tkp_prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/6}{}{0}} 4 | \headcommand {\beamer@framepages {2}{6}} 5 | \headcommand {\slideentry {0}{0}{3}{7/10}{}{0}} 6 | \headcommand {\beamer@framepages {7}{10}} 7 | \headcommand {\slideentry {0}{0}{4}{11/17}{}{0}} 8 | \headcommand {\beamer@framepages {11}{17}} 9 | \headcommand {\slideentry {0}{0}{5}{18/20}{}{0}} 10 | \headcommand {\beamer@framepages {18}{20}} 11 | \headcommand {\slideentry {0}{0}{6}{21/22}{}{0}} 12 | \headcommand {\beamer@framepages {21}{22}} 13 | \headcommand {\slideentry {0}{0}{7}{23/26}{}{0}} 14 | \headcommand {\beamer@framepages {23}{26}} 15 | \headcommand {\beamer@partpages {1}{26}} 16 | \headcommand {\beamer@subsectionpages {1}{26}} 17 | \headcommand {\beamer@sectionpages {1}{26}} 18 | \headcommand {\beamer@documentpages {26}} 19 | \headcommand {\gdef \inserttotalframenumber {7}} 20 | -------------------------------------------------------------------------------- /tkp22prez/andras_kovacs_tkp_prez.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/andras_kovacs_tkp_prez.out -------------------------------------------------------------------------------- /tkp22prez/andras_kovacs_tkp_prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/andras_kovacs_tkp_prez.pdf -------------------------------------------------------------------------------- /tkp22prez/andras_kovacs_tkp_prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/andras_kovacs_tkp_prez.snm -------------------------------------------------------------------------------- /tkp22prez/andras_kovacs_tkp_prez.toc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/andras_kovacs_tkp_prez.toc -------------------------------------------------------------------------------- /tkp22prez/prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/6}{}{0}} 4 | \headcommand {\beamer@framepages {2}{6}} 5 | \headcommand {\slideentry {0}{0}{3}{7/10}{}{0}} 6 | \headcommand {\beamer@framepages {7}{10}} 7 | \headcommand {\slideentry {0}{0}{4}{11/17}{}{0}} 8 | \headcommand {\beamer@framepages {11}{17}} 9 | \headcommand {\slideentry {0}{0}{5}{18/20}{}{0}} 10 | \headcommand {\beamer@framepages {18}{20}} 11 | \headcommand {\slideentry {0}{0}{6}{21/22}{}{0}} 12 | \headcommand {\beamer@framepages {21}{22}} 13 | \headcommand {\slideentry {0}{0}{7}{23/26}{}{0}} 14 | \headcommand {\beamer@framepages {23}{26}} 15 | \headcommand {\beamer@partpages {1}{26}} 16 | \headcommand {\beamer@subsectionpages {1}{26}} 17 | \headcommand {\beamer@sectionpages {1}{26}} 18 | \headcommand {\beamer@documentpages {26}} 19 | \headcommand {\gdef \inserttotalframenumber {7}} 20 | -------------------------------------------------------------------------------- /tkp22prez/prez.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/prez.out -------------------------------------------------------------------------------- /tkp22prez/prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/prez.pdf -------------------------------------------------------------------------------- /tkp22prez/prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/prez.snm -------------------------------------------------------------------------------- /tkp22prez/prez.toc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp22prez/prez.toc -------------------------------------------------------------------------------- /tkp23prez/tkp23prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/11}{}{0}} 6 | \headcommand {\beamer@framepages {5}{11}} 7 | \headcommand {\slideentry {0}{0}{4}{12/15}{}{0}} 8 | \headcommand {\beamer@framepages {12}{15}} 9 | \headcommand {\slideentry {0}{0}{5}{16/22}{}{0}} 10 | \headcommand {\beamer@framepages {16}{22}} 11 | \headcommand {\slideentry {0}{0}{6}{23/24}{}{0}} 12 | \headcommand {\beamer@framepages {23}{24}} 13 | \headcommand {\slideentry {0}{0}{7}{25/26}{}{0}} 14 | \headcommand {\beamer@framepages {25}{26}} 15 | \headcommand {\slideentry {0}{0}{8}{27/29}{}{0}} 16 | \headcommand {\beamer@framepages {27}{29}} 17 | \headcommand {\slideentry {0}{0}{9}{30/31}{}{0}} 18 | \headcommand {\beamer@framepages {30}{31}} 19 | \headcommand {\slideentry {0}{0}{10}{32/33}{}{0}} 20 | \headcommand {\beamer@framepages {32}{33}} 21 | \headcommand {\slideentry {0}{0}{11}{34/35}{}{0}} 22 | \headcommand {\beamer@framepages {34}{35}} 23 | \headcommand {\slideentry {0}{0}{12}{36/37}{}{0}} 24 | \headcommand {\beamer@framepages {36}{37}} 25 | \headcommand {\slideentry {0}{0}{13}{38/39}{}{0}} 26 | \headcommand {\beamer@framepages {38}{39}} 27 | \headcommand {\slideentry {0}{0}{14}{40/40}{}{0}} 28 | \headcommand {\beamer@framepages {40}{40}} 29 | \headcommand {\beamer@partpages {1}{40}} 30 | \headcommand {\beamer@subsectionpages {1}{40}} 31 | \headcommand {\beamer@sectionpages {1}{40}} 32 | \headcommand {\beamer@documentpages {40}} 33 | \headcommand {\gdef \inserttotalframenumber {14}} 34 | -------------------------------------------------------------------------------- /tkp23prez/tkp23prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp23prez/tkp23prez.pdf -------------------------------------------------------------------------------- /tkp23prez/tkp23prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/tkp23prez/tkp23prez.snm -------------------------------------------------------------------------------- /types2022/abstract.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 4 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 5 | \global\let\oldcontentsline\contentsline 6 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 7 | \global\let\oldnewlabel\newlabel 8 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 9 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 10 | \AtEndDocument{\ifx\hyper@anchor\@undefined 11 | \let\contentsline\oldcontentsline 12 | \let\newlabel\oldnewlabel 13 | \fi} 14 | \fi} 15 | \global\let\hyper@last\relax 16 | \gdef\HyperFirstAtBeginDocument#1{#1} 17 | \providecommand\HyField@AuxAddToFields[1]{} 18 | \providecommand\HyField@AuxAddToCoFields[2]{} 19 | \citation{twolevel} 20 | \citation{kiselyov14metaocaml} 21 | \citation{typed-th} 22 | \citation{twolevel} 23 | \citation{sterlingthesis} 24 | \citation{DBLP:journals/corr/abs-2201-00495} 25 | \citation{partial-evaluation} 26 | \citation{gratzer20multimodal} 27 | \citation{licata2018internal} 28 | \bibstyle{plain} 29 | \bibdata{references} 30 | \bibcite{twolevel}{1} 31 | \bibcite{gratzer20multimodal}{2} 32 | \bibcite{partial-evaluation}{3} 33 | \bibcite{kiselyov14metaocaml}{4} 34 | \bibcite{DBLP:journals/corr/abs-2201-00495}{5} 35 | \bibcite{licata2018internal}{6} 36 | \bibcite{sterlingthesis}{7} 37 | \bibcite{typed-th}{8} 38 | \newlabel{LastPage}{{}{}{}{page.}{}} 39 | \xdef\lastpage@lastpage{} 40 | \xdef\lastpage@lastpageHy{} 41 | -------------------------------------------------------------------------------- /types2022/abstract.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2019/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: abstract.aux 4 | The style file: plain.bst 5 | Database file #1: references.bib 6 | You've used 8 entries, 7 | 2118 wiz_defined-function locations, 8 | 557 strings with 5871 characters, 9 | and the built_in function-call counts, 3162 in all, are: 10 | = -- 307 11 | > -- 173 12 | < -- 5 13 | + -- 66 14 | - -- 57 15 | * -- 228 16 | := -- 528 17 | add.period$ -- 28 18 | call.type$ -- 8 19 | change.case$ -- 47 20 | chr.to.int$ -- 0 21 | cite$ -- 8 22 | duplicate$ -- 123 23 | empty$ -- 225 24 | format.name$ -- 57 25 | if$ -- 667 26 | int.to.chr$ -- 0 27 | int.to.str$ -- 8 28 | missing$ -- 8 29 | newline$ -- 43 30 | num.names$ -- 22 31 | pop$ -- 50 32 | preamble$ -- 1 33 | purify$ -- 41 34 | quote$ -- 0 35 | skip$ -- 93 36 | stack$ -- 0 37 | substring$ -- 159 38 | swap$ -- 42 39 | text.length$ -- 5 40 | text.prefix$ -- 0 41 | top$ -- 0 42 | type$ -- 30 43 | warning$ -- 0 44 | while$ -- 30 45 | width$ -- 9 46 | write$ -- 94 47 | -------------------------------------------------------------------------------- /types2022/abstract.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2022/abstract.out -------------------------------------------------------------------------------- /types2022/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2022/abstract.pdf -------------------------------------------------------------------------------- /types2022/prez/ConservativityStaging-AndrásKovács.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2022/prez/ConservativityStaging-AndrásKovács.pdf -------------------------------------------------------------------------------- /types2022/prez/prez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/4}{}{0}} 4 | \headcommand {\beamer@framepages {2}{4}} 5 | \headcommand {\slideentry {0}{0}{3}{5/10}{}{0}} 6 | \headcommand {\beamer@framepages {5}{10}} 7 | \headcommand {\slideentry {0}{0}{4}{11/12}{}{0}} 8 | \headcommand {\beamer@framepages {11}{12}} 9 | \headcommand {\slideentry {0}{0}{5}{13/14}{}{0}} 10 | \headcommand {\beamer@framepages {13}{14}} 11 | \headcommand {\slideentry {0}{0}{6}{15/16}{}{0}} 12 | \headcommand {\beamer@framepages {15}{16}} 13 | \headcommand {\slideentry {0}{0}{7}{17/18}{}{0}} 14 | \headcommand {\beamer@framepages {17}{18}} 15 | \headcommand {\slideentry {0}{0}{8}{19/20}{}{0}} 16 | \headcommand {\beamer@framepages {19}{20}} 17 | \headcommand {\slideentry {0}{0}{9}{21/21}{}{0}} 18 | \headcommand {\beamer@framepages {21}{21}} 19 | \headcommand {\slideentry {0}{0}{10}{22/24}{}{0}} 20 | \headcommand {\beamer@framepages {22}{24}} 21 | \headcommand {\slideentry {0}{0}{11}{25/25}{}{0}} 22 | \headcommand {\beamer@framepages {25}{25}} 23 | \headcommand {\beamer@partpages {1}{25}} 24 | \headcommand {\beamer@subsectionpages {1}{25}} 25 | \headcommand {\beamer@sectionpages {1}{25}} 26 | \headcommand {\beamer@documentpages {25}} 27 | \headcommand {\gdef \inserttotalframenumber {11}} 28 | -------------------------------------------------------------------------------- /types2022/prez/prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2022/prez/prez.pdf -------------------------------------------------------------------------------- /types2022/prez/prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2022/prez/prez.snm -------------------------------------------------------------------------------- /types2024/abstract.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{DBLP:phd/ethos/Coutts11} 4 | Duncan Coutts. 5 | \newblock {\em Stream fusion : practical shortcut fusion for coinductive 6 | sequence types}. 7 | \newblock PhD thesis, University of Oxford, {UK}, 2011. 8 | 9 | \bibitem{DBLP:conf/pepm/0001K24} 10 | Tomoaki Kobayashi and Oleg Kiselyov. 11 | \newblock Complete stream fusion for software-defined radio. 12 | \newblock In Gabriele Keller and Meng Wang, editors, {\em Proceedings of the 13 | 2024 {ACM} {SIGPLAN} International Workshop on Partial Evaluation and Program 14 | Manipulation, {PEPM} 2024, London, UK, 16 January 2024}, pages 57--69. {ACM}, 15 | 2024. 16 | 17 | \bibitem{staged2ltt} 18 | Andr{\'{a}}s Kov{\'{a}}cs. 19 | \newblock Staged compilation with two-level type theory. 20 | \newblock {\em Proc. {ACM} Program. Lang.}, 6({ICFP}):540--569, 2022. 21 | 22 | \bibitem{DBLP:conf/pepm/YallopK19} 23 | Jeremy Yallop and Oleg Kiselyov. 24 | \newblock Generating mutually recursive definitions. 25 | \newblock In Manuel~V. Hermenegildo and Atsushi Igarashi, editors, {\em 26 | Proceedings of the 2019 {ACM} {SIGPLAN} Workshop on Partial Evaluation and 27 | Program Manipulation, PEPM@POPL 2019, Cascais, Portugal, January 14-15, 28 | 2019}, pages 75--81. {ACM}, 2019. 29 | 30 | \end{thebibliography} 31 | -------------------------------------------------------------------------------- /types2024/abstract.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2022/dev/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: abstract.aux 4 | The style file: plain.bst 5 | Database file #1: references.bib 6 | Repeated entry---line 5196 of file references.bib 7 | : @phdthesis{DBLP:phd/ethos/Coutts11 8 | : , 9 | I'm skipping whatever remains of this entry 10 | You've used 4 entries, 11 | 2118 wiz_defined-function locations, 12 | 530 strings with 4975 characters, 13 | and the built_in function-call counts, 1452 in all, are: 14 | = -- 149 15 | > -- 56 16 | < -- 2 17 | + -- 20 18 | - -- 16 19 | * -- 89 20 | := -- 240 21 | add.period$ -- 14 22 | call.type$ -- 4 23 | change.case$ -- 17 24 | chr.to.int$ -- 0 25 | cite$ -- 4 26 | duplicate$ -- 62 27 | empty$ -- 120 28 | format.name$ -- 16 29 | if$ -- 316 30 | int.to.chr$ -- 0 31 | int.to.str$ -- 4 32 | missing$ -- 3 33 | newline$ -- 23 34 | num.names$ -- 12 35 | pop$ -- 19 36 | preamble$ -- 1 37 | purify$ -- 14 38 | quote$ -- 0 39 | skip$ -- 49 40 | stack$ -- 0 41 | substring$ -- 93 42 | swap$ -- 20 43 | text.length$ -- 2 44 | text.prefix$ -- 0 45 | top$ -- 0 46 | type$ -- 16 47 | warning$ -- 0 48 | while$ -- 18 49 | width$ -- 5 50 | write$ -- 48 51 | (There was 1 error message) 52 | -------------------------------------------------------------------------------- /types2024/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2024/abstract.pdf -------------------------------------------------------------------------------- /types2024/pres/AndrásKovács.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2024/pres/AndrásKovács.pdf -------------------------------------------------------------------------------- /types2024/pres/newprez.nav: -------------------------------------------------------------------------------- 1 | \headcommand {\slideentry {0}{0}{1}{1/1}{}{0}} 2 | \headcommand {\beamer@framepages {1}{1}} 3 | \headcommand {\slideentry {0}{0}{2}{2/2}{}{0}} 4 | \headcommand {\beamer@framepages {2}{2}} 5 | \headcommand {\slideentry {0}{0}{3}{3/3}{}{0}} 6 | \headcommand {\beamer@framepages {3}{3}} 7 | \headcommand {\slideentry {0}{0}{4}{4/5}{}{0}} 8 | \headcommand {\beamer@framepages {4}{5}} 9 | \headcommand {\slideentry {0}{0}{5}{6/6}{}{0}} 10 | \headcommand {\beamer@framepages {6}{6}} 11 | \headcommand {\slideentry {0}{0}{6}{7/7}{}{0}} 12 | \headcommand {\beamer@framepages {7}{7}} 13 | \headcommand {\slideentry {0}{0}{7}{8/8}{}{0}} 14 | \headcommand {\beamer@framepages {8}{8}} 15 | \headcommand {\slideentry {0}{0}{8}{9/9}{}{0}} 16 | \headcommand {\beamer@framepages {9}{9}} 17 | \headcommand {\slideentry {0}{0}{9}{10/12}{}{0}} 18 | \headcommand {\beamer@framepages {10}{12}} 19 | \headcommand {\slideentry {0}{0}{10}{13/13}{}{0}} 20 | \headcommand {\beamer@framepages {13}{13}} 21 | \headcommand {\slideentry {0}{0}{11}{14/14}{}{0}} 22 | \headcommand {\beamer@framepages {14}{14}} 23 | \headcommand {\slideentry {0}{0}{12}{15/15}{}{0}} 24 | \headcommand {\beamer@framepages {15}{15}} 25 | \headcommand {\slideentry {0}{0}{13}{16/16}{}{0}} 26 | \headcommand {\beamer@framepages {16}{16}} 27 | \headcommand {\slideentry {0}{0}{14}{17/17}{}{0}} 28 | \headcommand {\beamer@framepages {17}{17}} 29 | \headcommand {\slideentry {0}{0}{15}{18/18}{}{0}} 30 | \headcommand {\beamer@framepages {18}{18}} 31 | \headcommand {\beamer@partpages {1}{18}} 32 | \headcommand {\beamer@subsectionpages {1}{18}} 33 | \headcommand {\beamer@sectionpages {1}{18}} 34 | \headcommand {\beamer@documentpages {18}} 35 | \headcommand {\gdef \inserttotalframenumber {15}} 36 | -------------------------------------------------------------------------------- /types2024/pres/newprez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2024/pres/newprez.pdf -------------------------------------------------------------------------------- /types2024/pres/newprez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2024/pres/newprez.snm -------------------------------------------------------------------------------- /types2024/pres/newprez.vrb: -------------------------------------------------------------------------------- 1 | \frametitle{Polarization \& Closure-Freedom} 2 | 3 | How to compile this? 4 | \vspace{1em} 5 | \begin{verbatim} 6 | f : Bool → Int → Int 7 | f b = case b of True → λ x. x + 10 8 | False → λ x. x * 10 9 | \end{verbatim} 10 | And this? 11 | \begin{verbatim} 12 | f : Int → Int 13 | f x := 14 | let g y := x + y; 15 | g x + 10 16 | \end{verbatim} 17 | -------------------------------------------------------------------------------- /types2024/pres/newprez.xdv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/types2024/pres/newprez.xdv -------------------------------------------------------------------------------- /yonedaLF/awodey_hsuniv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/awodey_hsuniv.pdf -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/.gitignore: -------------------------------------------------------------------------------- 1 | acmart.cls 2 | acmart.pdf 3 | acmguide.pdf 4 | samples/sample-*.pdf 5 | *.log 6 | *.aux 7 | *.cfg 8 | *.glo 9 | *.idx 10 | *.toc 11 | *.ilg 12 | *.ind 13 | *.out 14 | *.lof 15 | *.lot 16 | *.bbl 17 | *.blg 18 | *.gls 19 | *.cut 20 | *.hd 21 | *.dvi 22 | *.ps 23 | *.thm 24 | *.tgz 25 | *.zip 26 | *.rpi 27 | *~ 28 | *.bcf 29 | *.run.xml 30 | samples/ACM-Reference-Format.bst 31 | samples/*.tex 32 | samples/*.bbx 33 | samples/*.cbx 34 | samples/*.dbx -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/acm-jdslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/draft/acmart-primary/acm-jdslogo.png -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/acmart.ins: -------------------------------------------------------------------------------- 1 | % 2 | % Doctrip file for acmart 3 | % This file is in public domain 4 | % $Id: acmart.ins,v 1.1 2015/11/23 22:42:55 boris Exp $ 5 | % 6 | \def\batchfile{acmart.ins} 7 | \input docstrip 8 | \keepsilent 9 | \showprogress 10 | 11 | 12 | \askforoverwritefalse 13 | 14 | \generate{% 15 | \file{acmart.cls}{\from{acmart.dtx}{class}} 16 | \file{acmart-tagged.cls}{\from{acmart.dtx}{class,tagged}} 17 | } 18 | 19 | \obeyspaces 20 | \Msg{*****************************************************}% 21 | \Msg{* Congratulations! You successfully generated the *}% 22 | \Msg{* acmart package. *}% 23 | \Msg{* *}% 24 | \Msg{* Please move the file acmart.cls to where LaTeX *}% 25 | \Msg{* files are stored in your system. The manual is *}% 26 | \Msg{* acmart.pdf. *}% 27 | \Msg{* *}% 28 | \Msg{* The package is released under LPPL *}% 29 | \Msg{* *}% 30 | \Msg{* Happy TeXing! *}% 31 | \Msg{*****************************************************}% -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/acmdatamodel.dbx: -------------------------------------------------------------------------------- 1 | % Teach biblatex about numpages field 2 | \DeclareDatamodelFields[type=field, datatype=literal]{numpages} 3 | \DeclareDatamodelEntryfields{numpages} 4 | 5 | % Teach biblatex about articleno field 6 | \DeclareDatamodelFields[type=field, datatype=literal]{articleno} 7 | \DeclareDatamodelEntryfields{articleno} 8 | 9 | % Teach biblatex about urls field 10 | \DeclareDatamodelFields[type=list, datatype=uri]{urls} 11 | \DeclareDatamodelEntryfields{urls} 12 | 13 | % Teach biblatex about school field 14 | \DeclareDatamodelFields[type=list, datatype=literal]{school} 15 | \DeclareDatamodelEntryfields[thesis]{school} 16 | 17 | \DeclareDatamodelFields[type=field, datatype=literal]{key} 18 | \DeclareDatamodelEntryfields{key} 19 | 20 | % Teach biblatex about lastaccessed field 21 | \DeclareDatamodelFields[type=field,datatype=literal]{lastaccessed} 22 | \DeclareDatamodelEntryfields{lastaccessed} 23 | 24 | % Teach biblatex about distincturl field 25 | \DeclareDatamodelFields[type=field, datatype=literal]{distinctURL} 26 | \DeclareDatamodelEntryfields{distinctURL} 27 | 28 | 29 | % 30 | % include software data model from biblatex-software 31 | % 32 | 33 | \blx@inputonce{software.dbx}{biblatex data model extension for software}{}{}{}{} 34 | -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/acmnumeric.cbx: -------------------------------------------------------------------------------- 1 | \ProvidesFile{acmnumeric.cbx}[2017-09-27 v0.1] 2 | 3 | \RequireCitationStyle{numeric} 4 | 5 | \endinput 6 | -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/samples/sample-franklin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/draft/acmart-primary/samples/sample-franklin.png -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/samples/samples.ins: -------------------------------------------------------------------------------- 1 | \def\batchfile{samples.ins} 2 | \input docstrip 3 | \keepsilent 4 | \showprogress 5 | 6 | 7 | \askforoverwritefalse 8 | 9 | \generate{% 10 | \file{sample-manuscript.tex}{\from{samples.dtx}{all,proceedings,bibtex,manuscript}} 11 | \file{sample-acmsmall.tex}{\from{samples.dtx}{all,journal,bibtex,acmsmall}} 12 | \file{sample-acmsmall-submission.tex}{\from{samples.dtx}{all,journal,bibtex,acmsmall-submission}} 13 | \file{sample-acmsmall-biblatex.tex}{\from{samples.dtx}{all,journal,acmsmall-biblatex}} 14 | \file{sample-acmlarge.tex}{\from{samples.dtx}{all,journal,bibtex,acmlarge}} 15 | \file{sample-acmtog.tex}{\from{samples.dtx}{all,journal,bibtex,acmtog}} 16 | \file{sample-sigconf.tex}{\from{samples.dtx}{all,proceedings,bibtex,sigconf}} 17 | \file{sample-sigconf-biblatex.tex}{\from{samples.dtx}{all,proceedings,sigconf-biblatex}} 18 | \file{sample-sigconf-authordraft.tex}{\from{samples.dtx}{all,proceedings,bibtex,authordraft}} 19 | \file{sample-sigconf-i13n.tex}{\from{samples.dtx}{all,proceedings,bibtex,sigconf-i13n}} 20 | \file{sample-sigconf-xelatex.tex}{\from{samples.dtx}{all,proceedings,bibtex,sigconf}} 21 | \file{sample-sigconf-lualatex.tex}{\from{samples.dtx}{all,proceedings,bibtex,sigconf}} 22 | \file{sample-sigplan.tex}{\from{samples.dtx}{all,proceedings,bibtex,sigplan}} 23 | \file{sample-acmsmall-conf.tex}{\from{samples.dtx}{all,proceedings,bibtex,acmsmall-conf}} 24 | \file{sample-acmtog-conf.tex}{\from{samples.dtx}{all,journal,proceedings,bibtex,acmtog-conf}} 25 | \file{sample-acmcp.tex}{\from{samples.dtx}{all,journal,acmcp}} 26 | \file{sample-acmengage.tex}{\from{acmengage.dtx}{acmengage}} 27 | \file{sample-acmsmall-tagged.tex}{\from{samples.dtx}{all,journal,acmsmall,tagged}} 28 | } 29 | 30 | -------------------------------------------------------------------------------- /yonedaLF/draft/acmart-primary/samples/sampleteaser.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/draft/acmart-primary/samples/sampleteaser.pdf -------------------------------------------------------------------------------- /yonedaLF/draft/comment.cut: -------------------------------------------------------------------------------- 1 | To Robert, for the bagels and explaining CMYK and color spaces. 2 | -------------------------------------------------------------------------------- /yonedaLF/draft/paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/draft/paper.pdf -------------------------------------------------------------------------------- /yonedaLF/old/YonedaLF.md: -------------------------------------------------------------------------------- 1 | 2 | # Yoneda Logical Framework 3 | 4 | ## Overview 5 | 6 | It's common in the metatheory of type theories to define models of object 7 | theories, do some constructions while working internally in a model, then 8 | externalize said constructions. For internal constructions, we can always use 9 | the "raw" components of a model, including De Bruijn indices, but that's very 10 | tedious. Instead, we want to use "usual" syntax with named binders. 11 | 12 | I describe here a type theory where for each internally defined model we get an 13 | internal notation and a way to switch between internal and external views. 14 | Similar internal notations have been used many times, but to my knowledge, 15 | without a rigorous specification. 16 | 17 | I call the theory **Yoneda Logical Framework** or YLF, because the 18 | internal/external switch is given simply by the Yoneda embedding. 19 | 20 | ## Syntax of YLF 21 | 22 | YLF has multiple modes, not unlike modal type theories, although it does not 23 | quite fit into any existing framework for modalities. 24 | 25 | - The "external" model is a vanilla extensional TT. 26 | - For each model M of a second-order algebraic theory that's defined in the external mode, 27 | there is an "internal" mode. In this mode, we have *dual context*, 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/chairEC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/chairEC.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/debug.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/debug.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/easychair.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/easychair.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/epic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/epic.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/logoEC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/logoEC.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/EasyChair3.5/throneEC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/EasyChair3.5/throneEC.jpg -------------------------------------------------------------------------------- /yonedaLF/types2025/abstract.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2022/dev/Debian) 2 | Capacity: max_strings=200000, hash_size=200000, hash_prime=170003 3 | The top-level auxiliary file: abstract.aux 4 | The style file: plain.bst 5 | Database file #1: references.bib 6 | You've used 9 entries, 7 | 2118 wiz_defined-function locations, 8 | 564 strings with 5894 characters, 9 | and the built_in function-call counts, 3265 in all, are: 10 | = -- 331 11 | > -- 146 12 | < -- 5 13 | + -- 58 14 | - -- 47 15 | * -- 220 16 | := -- 537 17 | add.period$ -- 30 18 | call.type$ -- 9 19 | change.case$ -- 48 20 | chr.to.int$ -- 0 21 | cite$ -- 9 22 | duplicate$ -- 135 23 | empty$ -- 243 24 | format.name$ -- 47 25 | if$ -- 695 26 | int.to.chr$ -- 0 27 | int.to.str$ -- 9 28 | missing$ -- 8 29 | newline$ -- 48 30 | num.names$ -- 22 31 | pop$ -- 44 32 | preamble$ -- 1 33 | purify$ -- 40 34 | quote$ -- 0 35 | skip$ -- 109 36 | stack$ -- 0 37 | substring$ -- 190 38 | swap$ -- 46 39 | text.length$ -- 5 40 | text.prefix$ -- 0 41 | top$ -- 0 42 | type$ -- 36 43 | warning$ -- 0 44 | while$ -- 31 45 | width$ -- 10 46 | write$ -- 106 47 | -------------------------------------------------------------------------------- /yonedaLF/types2025/abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/abstract.pdf -------------------------------------------------------------------------------- /yonedaLF/types2025/easychair.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/types2025/easychair.zip -------------------------------------------------------------------------------- /yonedaLF/wg6_2025/AndrasKovacs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/wg6_2025/AndrasKovacs.pdf -------------------------------------------------------------------------------- /yonedaLF/wg6_2025/prez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/wg6_2025/prez.pdf -------------------------------------------------------------------------------- /yonedaLF/wg6_2025/prez.snm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrasKovacs/staged/c0cf3a58dcc8919aff7fb21391a860f9e8e7df64/yonedaLF/wg6_2025/prez.snm --------------------------------------------------------------------------------