Refactor code generation to prepare for optimization passes

This commit is contained in:
2025-02-01 11:27:52 -08:00
parent 1490fc601b
commit fad966b1ec
14 changed files with 597 additions and 608 deletions

View File

@@ -5,11 +5,11 @@ import Prelude
-- We should test this at some point
ptype IORef : U U
pfunc primNewIORef uses (MkIORes MkUnit) : a. a IO (IORef a) := `(_, a) => (w) => MkIORes(null, [a], w)`
pfunc primReadIORef uses (MkIORes MkUnit) : a. IORef a IO a := `(_, ref) => (w) => MkIORes(null, ref[0], w)`
pfunc primNewIORef uses (MkIORes) : a. a IO (IORef a) := `(_, a) => (w) => Prelude_MkIORes(null, [a], w)`
pfunc primReadIORef uses (MkIORes) : a. IORef a IO a := `(_, ref) => (w) => Prelude_MkIORes(null, ref[0], w)`
pfunc primWriteIORef uses (MkIORes MkUnit) : a. IORef a a IO Unit := `(_, ref, a) => (w) => {
ref[0] = a
return MkIORes(null,MkUnit,w)
return Prelude_MkIORes(null,Prelude_MkUnit,w)
}`
newIORef : io a. {{HasIO io}} a io (IORef a)