summaryrefslogtreecommitdiff
path: root/lib/option.sail
blob: 514cf7bab5e3187093d4cb02253cfba2bb6bc6fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ifndef _OPTION
$define _OPTION

// The option type is treated specially by the lem backend, so it maps
// onto the lem maybe type. If the constructors are named differently,
// this won't work - also no other type should be created with
// constructors named Some or None.

union option('a: Type) = {
  Some : 'a,
  None : unit
}

val is_none : forall ('a : Type). option('a) -> bool

function is_none opt = match opt {
  Some(_) => false,
  None()  => true
}

val is_some : forall ('a : Type). option('a) -> bool

function is_some opt = match opt {
  Some(_) => true,
  None()  => false
}

$endif