blob: 24aafcafda2d7b07e8486dfead9a8996e99b276e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
(local Either {})
(local Left {})
(local Right {})
(setmetatable Right Either)
(setmetatable Left Either)
(fn Either.new [self x]
(local obj { :value (or x {}) })
(tset self "__index" self)
(setmetatable obj self))
(fn Either.of [x] (Right:new x))
(fn Right.map [self f] (Either.of (f self.value)))
(fn Left.map [self f] self)
{
: Either
: Left
: Right
}
|