Sha256: b30d2a232e02941bfd2ae1adb8f8891871d7c83e1ff4830d43bab36b8f078ddb
Contents?: true
Size: 1.12 KB
Versions: 19
Compression:
Stored size: 1.12 KB
Contents
module Funkr module Categories module Applicative def apply raise "Applicative#apply not implemented" end module ClassMethods def curry_lift_proc(&block) self.pure(block.curry) end def full_lift_proc(&block) lambda do |*args| args.inject(curry_lift_proc(&block)) do |a,e| a.apply(e) end end end def lift_with(*args, &block) full_lift_proc(&block).call(*args) end end def <=>(other) proxy_comp(other){|a,b| a <=> b} end def ==(other) proxy_comp(other){|a,b| a == b} end def <(other) proxy_comp(other){|a,b| a < b} end def <=(other) proxy_comp(other){|a,b| a <= b} end def >(other) proxy_comp(other){|a,b| a > b} end def >=(other) proxy_comp(other){|a,b| a >= b} end private def proxy_comp(other,&block) self.class. curry_lift_proc(&block). apply(self).apply(other) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems