Module: Funkr::Categories::Applicative::ClassMethods

Defined in:
lib/funkr/categories/applicative.rb

Instance Method Summary collapse

Instance Method Details

#curry_lift_proc(&block) ⇒ Object

Curryfy the lambda block, and lift it into the functor



17
18
19
# File 'lib/funkr/categories/applicative.rb', line 17

def curry_lift_proc(&block)
  self.pure(block.curry)
end

#full_lift_proc(&block) ⇒ Object

Curryfy the lambda block over N parameter, lifting it to a lambda over N functors



23
24
25
26
27
28
29
# File 'lib/funkr/categories/applicative.rb', line 23

def full_lift_proc(&block)
  lambda do |*args|
    args.inject(curry_lift_proc(&block)) do |a,e|
      a.apply(e)
    end
  end
end

#lift_with(*args, &block) ⇒ Object

Lift the block and call parameters on it.



32
33
34
# File 'lib/funkr/categories/applicative.rb', line 32

def lift_with(*args, &block)
  full_lift_proc(&block).call(*args)
end