Add constraints to typechecker, fix old tests, add new ones
This commit is contained in:
@@ -29,9 +29,11 @@ namespace List =
|
||||
[] => abort("drop_last_unsafe: list empty")
|
||||
|
||||
|
||||
function contains(e : 'a, l : list('a)) = switch(l)
|
||||
[] => false
|
||||
h::t => h == e || contains(e, t)
|
||||
function
|
||||
contains : 'a is eq; ('a, list('a)) => bool
|
||||
contains(e, l) = switch(l)
|
||||
[] => false
|
||||
h::t => h == e || contains(e, t)
|
||||
|
||||
/** Finds first element of `l` fulfilling predicate `p` as `Some` or `None`
|
||||
* if no such element exists.
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace Option =
|
||||
None => abort(err)
|
||||
Some(x) => x
|
||||
|
||||
function contains(e : 'a, o : option('a)) = o == Some(e)
|
||||
function
|
||||
contains : 'a is eq; ('a, option('a)) => bool
|
||||
contains(e, o) = o == Some(e)
|
||||
|
||||
function on_elem(o : option('a), f : 'a => unit) : unit = match((), f, o)
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace String =
|
||||
Some(ix)
|
||||
|
||||
private function
|
||||
is_prefix : (list(char), list(char)) => option(list(char))
|
||||
is_prefix([], ys) = Some(ys)
|
||||
is_prefix(_, []) = None
|
||||
is_prefix(x :: xs, y :: ys) =
|
||||
|
||||
Reference in New Issue
Block a user