lib/ribimaybe.rb in ribimaybe-0.0.4 vs lib/ribimaybe.rb in ribimaybe-0.0.5
- old
+ new
@@ -174,41 +174,12 @@
# Just { |x| x } # => Just(#<Proc:0x007fdecc03a478@(irb):6>)
#
Contract Any, Or[nil, Proc] => Or[Nothing, Just]
def Just(value = nil, &fn)
return Nothing unless (value || fn)
- Just.new(value || fn)
+ Just.new(value || fn.curry)
end
- # Wraps a value in a Just or returns a Nothing.
- #
- # ==== Attributes
- #
- # * +value+ - Value to be wrapped.
- #
- # ==== Examples
- #
- # pure(nil) # => Nothing
- # pure(1) # => Just(1)
- #
- Contract Any => Or[Nothing, Just]
- def pure(value)
- Maybe(value)
- end
-
- # Wraps a value in a Just or returns a Nothing.
- #
- # ==== Attributes
- #
- # * +value+ - Value to be wrapped.
- #
- # ==== Examples
- #
- # rturn(nil) # => Nothing
- # rturn(1) # => Just(1)
- #
- Contract Any => Or[Nothing, Just]
- def rturn(value)
- pure(value)
- end
+ alias_method :pure, :Just
+ alias_method :rturn, :Just
end
end