
* Allow block with separate type signature and definition of a function For instance, ``` function add : (int, int) => int add(x, y) = x + y ``` cc #196 * Allow pattern matching in left-hand sides * Changelog * Fix type spec * partial case-on-constructor * Changelog for pattern-matching lets
23 lines
499 B
Plaintext
23 lines
499 B
Plaintext
contract LHSMatching =
|
|
|
|
function from_some(Some(x)) = x
|
|
|
|
function
|
|
length : list('a) => int
|
|
length([]) = 0
|
|
length(_ :: xs) = 1 + length(xs)
|
|
|
|
function
|
|
append([], ys) = ys
|
|
append(x :: xs, ys) = x :: append(xs, ys)
|
|
|
|
function local_match(xs : list('a)) =
|
|
let null([]) = true
|
|
let null(_ :: _) = false
|
|
!null(xs)
|
|
|
|
entrypoint main() =
|
|
from_some(Some([0]))
|
|
++ append([length([true]), 2, 3], [4, 5, 6])
|
|
++ [7 | if (local_match([false]))]
|