Skip to content

Commit 45cc9c4

Browse files
committed
wip
1 parent f20d417 commit 45cc9c4

File tree

2 files changed

+34
-5
lines changed
  • src/Juvix/Compiler/Internal/Translation/FromInternal/Analysis/TypeChecking/Traits
  • tests/Compilation/positive

2 files changed

+34
-5
lines changed

src/Juvix/Compiler/Internal/Translation/FromInternal/Analysis/TypeChecking/Traits/Resolver.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ lookupInstance' visited ctab tab name params
248248
return True
249249
(InstanceParamApp app1, InstanceParamApp app2)
250250
| app1 ^. instanceAppHead == app2 ^. instanceAppHead -> do
251-
and <$> sequence (zipWithExact (goMatch assignMetas) (app1 ^. instanceAppArgs) (app2 ^. instanceAppArgs))
251+
andM (zipWithExact (goMatch assignMetas) (app1 ^. instanceAppArgs) (app2 ^. instanceAppArgs))
252252
(InstanceParamFun fun1, InstanceParamFun fun2) -> do
253253
l <- goMatch assignMetas (fun1 ^. instanceFunLeft) (fun2 ^. instanceFunLeft)
254254
r <- goMatch assignMetas (fun1 ^. instanceFunRight) (fun2 ^. instanceFunRight)

tests/Compilation/positive/test092.juvix

+33-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ module test092;
22

33
import Stdlib.Prelude as Prelude open;
44

5-
two : Nat := suc (suc zero);
5+
n1 : Nat := suc zero;
6+
n2 : Nat := suc n1;
7+
n3 : Nat := suc n2;
8+
n4 : Nat := suc n3;
9+
n5 : Nat := suc n4;
10+
n6 : Nat := suc n5;
611

712
type uint (bytes : Nat) := mk Nat
813
with
@@ -14,10 +19,34 @@ with
1419
};
1520
end;
1621

22+
module Le;
23+
syntax operator '<= comparison;
24+
25+
trait
26+
type '<= (a b : Nat) := truth
27+
with
28+
instance
29+
le-zero {a : Nat} : zero '<= a := truth;
30+
31+
instance
32+
le-suc {a b : Nat} {{a '<= b}} : suc a '<= suc b := truth;
33+
end;
34+
35+
test (a b : Nat) {{a '<= b}} : Unit := unit;
36+
37+
example1 : Unit := test n1 n4;
38+
example2 : Unit := test n4 n4;
39+
example3 : Unit := test 1 3;
40+
end;
41+
1742
main : _ :=
1843
let
19-
e : uint two := uint.mk 5;
44+
z : uint zero := uint.mk 5;
45+
e : uint n2 := uint.mk 5;
2046
e3 : uint (suc (suc (suc zero))) := uint.mk 5;
2147
e4 : uint 7 := uint.mk 87;
22-
in printStringLn (Show.show e) >>>
23-
printStringLn (Show.show e3) >>> printStringLn (Show.show e4);
48+
in printStringLn (Show.show z)
49+
>>> printStringLn (Show.show e)
50+
>>> printStringLn (Show.show e3)
51+
>>> printStringLn (Show.show e3)
52+
>>> printStringLn (Show.show e4);

0 commit comments

Comments
 (0)