repo.or.cz
/
ruby-do-notation.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Simplified Maybe
[ruby-do-notation.git]
/
lib
/
maybe.rb
blob
c333d45a7288ce5fa39f47149d7a0bf1d6c597e5
1
class Maybe
2
extend Monad
3
4
class << self
5
alias_method :unit, :new
6
end
7
8
attr_accessor :value
9
10
def initialize value
11
@value = value
12
end
13
14
def bind &f
15
if value.nil?
16
self
17
else
18
f.call(value)
19
end
20
end
21
end