Add some more type inference tests
This commit is contained in:
parent
85528ad8af
commit
0eada4068c
1 changed files with 29 additions and 2 deletions
|
@ -70,8 +70,7 @@ let is_odd x.
|
||||||
not (is_even True)
|
not (is_even True)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Polymorphic records can be partially typed
|
||||||
### Polymorphic records can be partially typed
|
|
||||||
|
|
||||||
```
|
```
|
||||||
struct Timestamped a b.
|
struct Timestamped a b.
|
||||||
|
@ -85,3 +84,31 @@ type Bar = Foo Int
|
||||||
|
|
||||||
let t : Bar = Timestamped { first = "bar", second = 1, timestamp = 12345 }
|
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")
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue