Skip to content

Commit cc25eed

Browse files
Merge pull request #1282 from andrew-johnson-4/contravariance-arrows
Contravariance arrows
2 parents 677129a + 6c8db50 commit cc25eed

File tree

6 files changed

+24578
-24405
lines changed

6 files changed

+24578
-24405
lines changed

BOOTSTRAP/cli.c

Lines changed: 24559 additions & 24403 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.20.57"
3+
version = "1.20.58"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC = cc
22

33
dev: install-production
4-
lm tests/regress/numerical-pyramid.lsts
4+
lm tests/unit/type-inference.lsts
55
$(CC) -O3 tmp.c
66
./a.out
77
#lm tests/c/main.c

SRC/can-unify.lsts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ let can-unify(fpt: Type, pt: Type): U64 = (
6767
second:rp1
6868
} => can-unify(lp1,rp1);
6969

70+
Tuple{
71+
first:TGround{tag:c"Arrow", parameters:[lrng.. ldom..]},
72+
second:TGround{tag:c"Arrow", parameters:[rrng.. rdom..]}
73+
} => can-unify(rdom, ldom) && can-unify(ldom, rdom);
74+
7075
Tuple{
7176
first:TGround{ltn=tag, lps=parameters},
7277
second:TGround{rtn=tag, rps=parameters}

SRC/unify.lsts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ let unify-inner(fpt: Type, pt: Type): Maybe<TContext> = (
7373
second:rp1
7474
} => ctx = unify-inner(lp1,rp1);
7575

76+
Tuple{
77+
first:TGround{tag:c"Arrow", parameters:[lrng.. ldom..]},
78+
second:TGround{tag:c"Arrow", parameters:[rrng.. rdom..]}
79+
} => (ctx = unify-inner(rdom, ldom) && unify-inner(ldom, rdom));
80+
7681
Tuple{
7782
first:TGround{ltn=tag, lps=parameters},
7883
second:TGround{rtn=tag, rps=parameters}

tests/unit/type-inference.lsts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ if true {
3434
let tctx = unify(t-array-x, t-array-A-d);
3535
assert( substitute(tctx, t-x) == t-A );
3636
};
37+
38+
let t-f1 = normalize(t3(c"Arrow", t-A, t-A));
39+
let t-f2 = normalize(t3(c"Arrow", t-C, t-A));
40+
let t-f3 = normalize(t3(c"Arrow", t-A, t-C));
41+
42+
assert( not(can-unify(t-f2, t-f1)) );
43+
assert( can-unify(t-f3, t-f1) );

0 commit comments

Comments
 (0)