diff --git a/src/test/type-inference.md b/src/test/type-inference.md index 19b7c4cf7..fd36db41f 100644 --- a/src/test/type-inference.md +++ b/src/test/type-inference.md @@ -70,8 +70,7 @@ let is_odd x. not (is_even True) ``` - -### Polymorphic records can be partially typed +## Polymorphic records can be partially typed ``` struct Timestamped a b. @@ -85,3 +84,31 @@ type Bar = Foo Int let t : Bar = Timestamped { first = "bar", second = 1, timestamp = 12345 } ``` + +## Extensible records work + +``` +struct Timestamped a. + data: a + timestamp: Int + +let t = Timestamped { data = "foo", timestamp = 12345 } + +t.data == 1 +t.data == "foo" + +let u = Timestamped { data = True, timestamp = 12345 } + +u.data == "foo" +u.data == False +``` + +## A recursive function is automatically instantiated + +``` +let fac n. + if n == 0. + return 1 + else. + return n * fac (n-"foo") +```