Skip to content

Commit bf88416

Browse files
committed
Update types example to use requires #14
The types example has been updated to use requires in a few places instead of "if". Currently, this does not compile --- see #24
1 parent 9b60756 commit bf88416

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

examples/types/Types.wyrl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ reduce Intersect{Type x}:
3838
reduce Intersect{Not(Any), Type... xs}:
3939
=> Not(Any)
4040

41-
reduce Intersect{Any, Type... xs}:
42-
=> Intersect (xs), if |xs| > 0
41+
reduce Intersect{Any, Type... xs}
42+
requires |xs| > 0:
43+
=> Intersect (xs)
4344

4445
reduce Intersect{Int, Pair y, Type... ys}:
4546
=> Not(Any)
4647

4748
reduce Intersect{Intersect{Type... xs}, Type... ys}:
4849
=> Intersect (xs ++ ys)
4950

50-
reduce Intersect{Not(Type x), Type y, Type... ys}:
51-
=> Not(Any), if x == y
51+
reduce Intersect{Not(Type x), Type y, Type... ys}
52+
requires x == y:
53+
=> Not(Any)
5254

5355
reduce Intersect{Union{Type... xs}, Type... ys}:
5456
=> let ys = { Intersect(x ++ ys) | x in xs }
@@ -76,8 +78,9 @@ reduce Union{Not(Any), Type... xs}:
7678
=> Union (xs), if |xs| > 0
7779
=> Not(Any)
7880

79-
reduce Union{Not(Type x), Type y, Type... ys}:
80-
=> Any, if x == y
81+
reduce Union{Not(Type x), Type y, Type... ys}
82+
requires x == y:
83+
=> Any
8184

8285
reduce Union{Union{Type... xs}, Type... ys}:
8386
=> Union (xs ++ ys)

0 commit comments

Comments
 (0)