ok fuck rescript

[?]
Nov 2, 2023, 3:50 AM
ID2WJIDOVGFNLXEJQAEHCKZ425N2FOB6TO2MVMW475MYNR2ONE2QC

Dependencies

Change contents

  • edit in src/data.res at line 1
    [2.87][2.88:172]()
    // Disable warning about the same constructor for different types
    @@warning("-30")
  • replacement in src/data.res at line 9
    [2.325][2.325:458]()
    | Unit // 1
    | Var(string) // α
    | Existential(string) // â
    | Polytype(string, typ) // ∀α.A
    | Arrow(typ, typ) // A -> B
    [2.325]
    [2.458]
    | TUnit // 1
    | TVar(string) // α
    | TExistential(string) // â
    | TPolytype(string, typ) // ∀α.A
    | TArrow(typ, typ) // A -> B
  • replacement in src/data.res at line 17
    [2.492][2.492:598]()
    | Unit // 1
    | Var(string) // α
    | Existential(string) // â
    | Arrow(monotyp, monotyp) // τ -> σ
    [2.492]
    [2.598]
    | MUnit // 1
    | MVar(string) // α
    | MExistential(string) // â
    | MArrow(monotyp, monotyp) // τ -> σ
  • replacement in src/data.res at line 30
    [2.841][2.841:990]()
    | TypeVar(string) // Ω,α
    | TermAnnot(string, typ) // Ω,x:A
    | ExistentialSolved(string, monotyp) // Ω,â=τ
    | Marker(string) // Ω,🢒â
    [2.841]
    [2.990]
    | CCTypeVar(string) // Ω,α
    | CCTermAnnot(string, typ) // Ω,x:A
    | CCExistentialSolved(string, monotyp) // Ω,â=τ
    | CCMarker(string) // Ω,🢒â
  • edit in src/data.res at line 37
    [2.1026][2.1026:1044]()
    @@warning("+30")
  • replacement in src/data.res at line 38
    [2.1066][2.1066:1145]()
    let rec lookupTypeVariable = (ctx: list<contextEntry>, name: string): typ => {
    [2.1066]
    [2.1145]
    let rec lookupTypeVariable = (ctx: list<contextEntry>, name: string): result<typ, string> => {
  • replacement in src/data.res at line 40
    [2.1160][2.1160:1238]()
    | list{} => failwith("L")
    | list{TermAnnot(n, t), ..._} if n == name => t
    [2.1160]
    [2.1238]
    | list{} => Error(`could not find name ${name}`)
    | list{TermAnnot(n, t), ..._} if n == name => Ok(t)
  • replacement in src/bidir.res at line 8
    [2.1482][2.1482:1516]()
    `${prefix}${Int.toString(num)}`
    [2.1482]
    [2.1516]
    `${prefix}${num->Int.toString}`
  • replacement in src/bidir.res at line 20
    [2.1783][2.1783:1811]()
    | (Unit, Unit) => Ok(ctx)
    [2.1783]
    [2.1811]
    | (Unit, TUnit) => Ok(ctx)
  • replacement in src/bidir.res at line 23
    [2.1827][2.1827:1873]()
    | (e, Polytype(x, tyA)) => failwith("TODO")
    [2.1827]
    [2.1873]
    | (e, TPolytype(x, tyA)) => failwith("TODO ∀I-rule")
  • replacement in src/bidir.res at line 26
    [2.1889][2.1889:1925]()
    | (Lam(x, e), Arrow(tyA, tyB)) =>
    [2.1889]
    [2.1925]
    | (Lam(x, e), TArrow(tyA, tyB)) =>
  • replacement in src/bidir.res at line 31
    [2.2054][2.2054:2194]()
    // TODO: Subtyping rule???
    | (Var(_) | Lam(_, _) | App(_, _) | Annot(_, _), _) => failwith("TODO")
    | _ => Error("could not resolve")
    [2.2054]
    [2.2194]
    | (_, _) =>
    let tyA = synthesize(ctx, term)
    let tyA' = applyContext(ctx, tyA)
  • replacement in src/bidir.res at line 40
    [2.2312][2.2312:2368]()
    | Var(name) => Ok(lookupTypeVariable(ctx, name), ctx)
    [2.2312]
    [2.2368]
    | Var(name) => lookupTypeVariable(ctx, name)->Result.map(ty => (ty, ctx))
  • replacement in src/bidir.res at line 43
    [2.2385][2.2385:2411]()
    | Unit => Ok(Unit, ctx)
    [2.2385]
    [2.2411]
    | Unit => Ok(TUnit, ctx)
  • replacement in src/bidir.res at line 53
    [2.2643][2.2643:2698]()
    Ok(Arrow(Existential(exA), Existential(exB)), ctx)
    [2.2643]
    [2.2698]
    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
    [2.2714][2.2714:2750]()
    | App(e1, e2) => failwith("TODO")
    [2.2714]
    [2.2750]
    | App(e1, e2) => synthesize(ctx, e1)->Result.flatMap(((tyA, ctx)) => appSynthesize(ctx, tyA, e2))
  • replacement in src/bidir.res at line 67
    [2.2895][2.2895:2975]()
    | (Arrow(tyA, tyC), e) => typecheck(ctx, e, tyA)->Result.map(_ => (tyC, ctx))
    [2.2895]
    [2.2975]
    | (TArrow(tyA, tyC), e) => typecheck(ctx, e, tyA)->Result.map(_ => (tyC, ctx))
  • replacement in src/bidir.res at line 70
    [2.2993][2.2993:3039]()
    | (Polytype(a, tyA), e) => failwith("TODO")
    [2.2993]
    [2.3039]
    | (TPolytype(a, tyA), e) => failwith("TODO")
  • replacement in src/bidir.res at line 73
    [2.3056][2.3056:3100]()
    | (Existential(_), _) => failwith("TODO")
    [2.3056]
    [2.3100]
    | (TExistential(_), _) => failwith("TODO")
  • replacement in src/bidir.res at line 75
    [2.3101][2.3101:3185]()
    | (Unit | Var(_), _) => Error("trying to appSynthesize with a non-function type")
    [2.3101]
    [2.3185]
    | (TUnit | TVar(_), _) => Error("trying to appSynthesize with a non-function type")
  • replacement in src/bidir.res at line 80
    [2.3254][2.3254:3312]()
    let rec applyContext = (ctx: context, typ: typ): typ => {
    [2.3254]
    [2.3312]
    and applyContext = (ctx: context, typ: typ): typ => {
  • replacement in src/bidir.res at line 82
    [2.3327][2.3327:3509]()
    | Unit => Unit
    | Var(x) => Var(x)
    | Existential(_) => failwith("TODO")
    | Polytype(_) => failwith("TODO")
    | Arrow(a, b) => Arrow(applyContext(ctx, a), applyContext(ctx, b))
    [2.3327]
    [2.3509]
    | 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
    [2.3624][2.3624:3659]()
    "res:dev": "rescript build -w"
    [2.3624]
    [2.3659]
    "res:dev": "rescript build -w",
    "test": "retest lib/**/*.mjs"
  • replacement in package.json at line 8
    [2.3687][2.3687:3713]()
    "rescript": "^10.1.4"
    [2.3687]
    [2.3713]
    "@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][2.3763:5146]()
    [2.3762]
  • edit in bsconfig.json at line 3
    [2.5203]
    [2.5203]
    "bsc-flags": [],
  • replacement in bsconfig.json at line 5
    [2.5218][2.5218:5272]()
    {
    "dir": "src",
    "subdirs": true
    }
    [2.5218]
    [2.5272]
    { "dir": "src", "subdirs": true },
    { "dir": "__tests__", "subdirs": true, "type": "dev" }
  • replacement in bsconfig.json at line 10
    [2.5304][2.5304:5327]()
    "module": "es6",
    [2.5304]
    [2.5327]
    "module": "commonjs",
  • replacement in bsconfig.json at line 15
    [2.5384][2.5384:5408]()
    "bs-dependencies": []
    [2.5384]
    [2.5408]
    "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__ (d--r------)
    [5.2]
  • file addition: terms_test.res (----------)
    [0.280170]
    open Jest
    open Belt
    open Data
    open Bidir
    open Expect
    open! Expect.Operators
    let mapFirst = a => a->Result.map(((x, _)) => x)
    test("id", () => {
    let id: term = Lam("x", Var("x"))
    let ctx = list{}
    let typ = synthesize(ctx, id)->mapFirst
    Js.Console.error2("output: ", typ)
    expect(typ) === Ok(TPolytype("ex0", TArrow(TVar("ex0"), TVar("ex0"))))
    })
  • edit in .gitignore at line 5
    [2.5461]
    [2.5461]
    *.bs.mjs
  • replacement in .gitignore at line 9
    [2.5483][2.5483:5489]()
    lib/bs
    [2.5483]
    lib/bs
    __tests__/**/*.mjs
    src/**/*.mjs