ok fuck rescript
[?]
Nov 2, 2023, 3:50 AM
ID2WJIDOVGFNLXEJQAEHCKZ425N2FOB6TO2MVMW475MYNR2ONE2QCDependencies
Change contents
- edit in src/data.res at line 1
// Disable warning about the same constructor for different types@@warning("-30") - replacement in src/data.res at line 9
| Unit // 1| Var(string) // α| Existential(string) // â| Polytype(string, typ) // ∀α.A| Arrow(typ, typ) // A -> B| TUnit // 1| TVar(string) // α| TExistential(string) // â| TPolytype(string, typ) // ∀α.A| TArrow(typ, typ) // A -> B - replacement in src/data.res at line 17
| Unit // 1| Var(string) // α| Existential(string) // â| Arrow(monotyp, monotyp) // τ -> σ| MUnit // 1| MVar(string) // α| MExistential(string) // â| MArrow(monotyp, monotyp) // τ -> σ - replacement in src/data.res at line 30
| TypeVar(string) // Ω,α| TermAnnot(string, typ) // Ω,x:A| ExistentialSolved(string, monotyp) // Ω,â=τ| Marker(string) // Ω,🢒â| CCTypeVar(string) // Ω,α| CCTermAnnot(string, typ) // Ω,x:A| CCExistentialSolved(string, monotyp) // Ω,â=τ| CCMarker(string) // Ω,🢒â - edit in src/data.res at line 37
@@warning("+30") - replacement in src/data.res at line 38
let rec lookupTypeVariable = (ctx: list<contextEntry>, name: string): typ => {let rec lookupTypeVariable = (ctx: list<contextEntry>, name: string): result<typ, string> => { - replacement in src/data.res at line 40
| list{} => failwith("L")| list{TermAnnot(n, t), ..._} if n == name => t| list{} => Error(`could not find name ${name}`)| list{TermAnnot(n, t), ..._} if n == name => Ok(t) - replacement in src/bidir.res at line 8
`${prefix}${Int.toString(num)}``${prefix}${num->Int.toString}` - replacement in src/bidir.res at line 20
| (Unit, Unit) => Ok(ctx)| (Unit, TUnit) => Ok(ctx) - replacement in src/bidir.res at line 23
| (e, Polytype(x, tyA)) => failwith("TODO")| (e, TPolytype(x, tyA)) => failwith("TODO ∀I-rule") - replacement in src/bidir.res at line 26
| (Lam(x, e), Arrow(tyA, tyB)) =>| (Lam(x, e), TArrow(tyA, tyB)) => - replacement in src/bidir.res at line 31
// TODO: Subtyping rule???| (Var(_) | Lam(_, _) | App(_, _) | Annot(_, _), _) => failwith("TODO")| _ => Error("could not resolve")| (_, _) =>let tyA = synthesize(ctx, term)let tyA' = applyContext(ctx, tyA) - replacement in src/bidir.res at line 40
| Var(name) => Ok(lookupTypeVariable(ctx, name), ctx)| Var(name) => lookupTypeVariable(ctx, name)->Result.map(ty => (ty, ctx)) - replacement in src/bidir.res at line 43
| Unit => Ok(Unit, ctx)| Unit => Ok(TUnit, ctx) - replacement in src/bidir.res at line 53
Ok(Arrow(Existential(exA), Existential(exB)), ctx)let augmentedCtx = list{TermAnnot(x, TVar(exA)), TypeVar(exB), TypeVar(exA), ...ctx}typecheck(augmentedCtx, e, TVar(exB))->Result.map(_ => (TArrow(TExistential(exA), TExistential(exB)),ctx,)) - replacement in src/bidir.res at line 60
| App(e1, e2) => failwith("TODO")| App(e1, e2) => synthesize(ctx, e1)->Result.flatMap(((tyA, ctx)) => appSynthesize(ctx, tyA, e2)) - replacement in src/bidir.res at line 67
| (Arrow(tyA, tyC), e) => typecheck(ctx, e, tyA)->Result.map(_ => (tyC, ctx))| (TArrow(tyA, tyC), e) => typecheck(ctx, e, tyA)->Result.map(_ => (tyC, ctx)) - replacement in src/bidir.res at line 70
| (Polytype(a, tyA), e) => failwith("TODO")| (TPolytype(a, tyA), e) => failwith("TODO") - replacement in src/bidir.res at line 73
| (Existential(_), _) => failwith("TODO")| (TExistential(_), _) => failwith("TODO") - replacement in src/bidir.res at line 75
| (Unit | Var(_), _) => Error("trying to appSynthesize with a non-function type")| (TUnit | TVar(_), _) => Error("trying to appSynthesize with a non-function type") - replacement in src/bidir.res at line 80
let rec applyContext = (ctx: context, typ: typ): typ => {and applyContext = (ctx: context, typ: typ): typ => { - replacement in src/bidir.res at line 82
| Unit => Unit| Var(x) => Var(x)| Existential(_) => failwith("TODO")| Polytype(_) => failwith("TODO")| Arrow(a, b) => Arrow(applyContext(ctx, a), applyContext(ctx, b))| TUnit => TUnit| TVar(x) => TVar(x)| TExistential(_) => failwith("TODO")| TPolytype(_) => failwith("TODO")| TArrow(a, b) => TArrow(applyContext(ctx, a), applyContext(ctx, b)) - replacement in package.json at line 4
"res:dev": "rescript build -w""res:dev": "rescript build -w","test": "retest lib/**/*.mjs" - replacement in package.json at line 8
"rescript": "^10.1.4""@glennsl/bs-jest": "^0.7.0","jest": "^29.7.0","rescript": "^10.1.4","rescript-js": "^1.0.0-beta.2","rescript-test": "^5.0.0" - file addition: jest.config.json[5.2]
{"verbose": true,"moduleFileExtensions": ["js", "mjs"],"extensionsToTreatAsEsm": [".bs.mjs"],"testMatch": ["**/__tests__/**/*_test.mjs", "**/__tests__/**/*_test.bs.js"],"transform": {"^.+.m?js$": "babel-jest"},"transformIgnorePatterns": ["node_modules/(?!(rescript)/)"]} - replacement in bun.lockb at line 1[2.3762]
- edit in bsconfig.json at line 3
"bsc-flags": [], - replacement in bsconfig.json at line 5
{"dir": "src","subdirs": true}{ "dir": "src", "subdirs": true },{ "dir": "__tests__", "subdirs": true, "type": "dev" } - replacement in bsconfig.json at line 10
"module": "es6","module": "commonjs", - replacement in bsconfig.json at line 15
"bs-dependencies": []"bs-dependencies": [],"bs-dev-dependencies": ["@glennsl/bs-jest"] - file addition: bidir-writeup.typ[5.2]
= Expressions- $ id : forall a. a arrow.r a $ - file addition: babel.config.js[5.2]
module.exports = {presets: [["@babel/preset-env",{ targets: { node: "current", esmodules: false }, modules: "cjs" },],],plugins: [],}; - file addition: __tests__[5.2]
- file addition: terms_test.res[0.280170]
open Jestopen Beltopen Dataopen Bidiropen Expectopen! Expect.Operatorslet mapFirst = a => a->Result.map(((x, _)) => x)test("id", () => {let id: term = Lam("x", Var("x"))let ctx = list{}let typ = synthesize(ctx, id)->mapFirstJs.Console.error2("output: ", typ)expect(typ) === Ok(TPolytype("ex0", TArrow(TVar("ex0"), TVar("ex0"))))}) - edit in .gitignore at line 5
*.bs.mjs - replacement in .gitignore at line 9
lib/bs[2.5483]lib/bs__tests__/**/*.mjssrc/**/*.mjs