forked from rafoo/dklib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dk_opt.dk
29 lines (25 loc) · 995 Bytes
/
dk_opt.dk
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
29
#NAME dk_opt.
(; options ;)
option : cc.uT -> cc.uT.
Option : cc.uT -> Type.
[A] cc.eT (option A) --> Option A.
None : A : cc.uT -> Option A.
Some : A : cc.uT -> cc.eT A -> Option A.
def match_option : A : cc.uT ->
P : (Option A -> cc.uT) ->
cc.eT (P (None A)) ->
(a : cc.eT A -> cc.eT (P (Some A a))) ->
o : Option A ->
cc.eT (P o).
[Hnone] match_option _ _ Hnone _ (None _) --> Hnone
[Hsome,a] match_option _ _ _ Hsome (Some _ a) --> Hsome a.
def simple_match_option : A : cc.uT ->
return : cc.uT ->
cc.eT return ->
(a : cc.eT A -> cc.eT return) ->
o : Option A ->
cc.eT return
:=
A : cc.uT =>
return : cc.uT =>
match_option A (_x : cc.eT (option A) => return).