module Divergent
Divergent
is a collection of monad class to do error handling in Ruby.
Currently, it only contains two class:
-
Try: a container which can wraps possible errors.
-
Maybe: a container which wraps nil case.
Constants
- VERSION
Public Class Methods
Maybe(v)
click to toggle source
# File lib/divergent/maybe.rb, line 235 def Maybe(v) Maybe.unit(v) end
Try() { || ... }
click to toggle source
Constructs a `Try` by calling the passed block. This method will ensure any StandardError is caught and a `Failure` object is returned.
# File lib/divergent/try.rb, line 296 def Try Try.unit { yield } end
Private Instance Methods
Maybe(v)
click to toggle source
# File lib/divergent/maybe.rb, line 235 def Maybe(v) Maybe.unit(v) end
Try() { || ... }
click to toggle source
Constructs a `Try` by calling the passed block. This method will ensure any StandardError is caught and a `Failure` object is returned.
# File lib/divergent/try.rb, line 296 def Try Try.unit { yield } end