Use null for erased values to aid serialization

This commit is contained in:
2025-01-18 14:48:29 -08:00
parent cecb1d73c1
commit f9279bb255
6 changed files with 43 additions and 28 deletions

View File

@@ -8,12 +8,12 @@ pfunc readFile uses (fs MkIORes Left Right) : (fn : String) -> IO (Either String
let result
try {
let content = fs.readFileSync(fn, 'utf8')
result = Right(undefined, undefined, content)
result = Right(null, null, content)
} catch (e) {
let err = ""+e
result = Left(undefined, undefined, e)
result = Left(null, null, e)
}
return MkIORes(undefined, result, w)
return MkIORes(null, result, w)
}`
-- I wonder if I should automatically `uses` the constructors in the types
@@ -21,12 +21,12 @@ pfunc writeFile uses (fs MkIORes MkUnit) : String → String → IO (Either Stri
let result
try {
fs.writeFileSync(fn, content, 'utf8')
result = Right(undefined, undefined, MkUnit)
result = Right(null, null, MkUnit)
} catch (e) {
let err = ""+e
result = Left(undefined, undefined, e)
result = Left(null, null, e)
}
return MkIORes(undefined, result, w)
return MkIORes(null, result, w)
}`
-- maybe System.exit or something, like the original putStrLn msg >> exitFailure