summaryrefslogtreecommitdiff
path: root/examples/either.sin
blob: e16b7b8d86ea8561620a6abaade1799cae203852 (plain) (blame)
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
[type left_  [kind val]]
[type right_ [kind val]]

[def left [val]
    [left_ 0 val]]

[def right [val]
    [right_ 1 val]]

[def left.val [x]
    [left_.val x]]

[def right.val [x]
    [right_.val x]]

[def is_right [x]
    [right_.kind x]]

[def Either.>>= [a f]
    [if [is_right a]
        [f [right.val a]]
        a]]

[def Either.return [x]
    [right x]]