class Proc

Public Class Methods

compose(f, g) click to toggle source
# File lib/totally_lazy/functions.rb, line 5
def self.compose(f, g)
  lambda { |*args| f[g[*args]] }
end

Public Instance Methods

*(g) click to toggle source
# File lib/totally_lazy/functions.rb, line 9
def *(g)
  Proc.compose(self, g)
end
and_then(g) click to toggle source
# File lib/totally_lazy/functions.rb, line 13
def and_then(g)
  Proc.compose(g, self)
end
optional() click to toggle source
# File lib/totally_lazy/option.rb, line 4
def optional
  ->(value) {
    begin
      Option.option(self.(value))
    rescue
      Option.none
    end
  }
end
or_exception() click to toggle source
# File lib/totally_lazy/either.rb, line 4
def or_exception
  -> (value) {
    begin
      right(self.(value))
    rescue Exception => e
      left(e)
    end
  }
end