mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
50 lines
933 B
Plaintext
50 lines
933 B
Plaintext
|
|
```catala
|
|
declaration structure Str:
|
|
data x1 content (integer, date)
|
|
|
|
declaration enumeration En:
|
|
-- One content Str
|
|
-- Two content (integer, Str)
|
|
|
|
declaration str content Str equals
|
|
Str { --x1: (12, |2001-01-01|) }
|
|
|
|
declaration f2 content decimal
|
|
depends on str content Str,
|
|
en content En
|
|
equals
|
|
match en with pattern
|
|
-- One of str1:
|
|
let a equals str.x1.1 in
|
|
let (b, w) equals str1.x1 in
|
|
a / b
|
|
-- Two of z:
|
|
let (z1, z2) equals z in z1 / 2
|
|
|
|
declaration scope Test:
|
|
output o content (date, decimal)
|
|
|
|
scope Test:
|
|
definition o equals
|
|
(|2001-01-03|,
|
|
f2 of str, Two content (12, str))
|
|
```
|
|
|
|
```catala-test-inline
|
|
$ catala typecheck --check-invariants
|
|
┌─[RESULT]─
|
|
│ All invariant checks passed
|
|
└─
|
|
┌─[RESULT]─
|
|
│ Typechecking successful!
|
|
└─
|
|
```
|
|
|
|
```catala-test-inline
|
|
$ catala test-scope Test
|
|
┌─[RESULT]─
|
|
│ o = (2001-01-03, 6.0)
|
|
└─
|
|
```
|