Class: Kleisli::Either

Inherits:
Monad show all
Defined in:
lib/kleisli/either.rb

Direct Known Subclasses

Left, Right

Defined Under Namespace

Classes: Left, Right

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Monad

#>, #>>

Methods inherited from Functor

#fmap

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



6
7
8
# File 'lib/kleisli/either.rb', line 6

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



6
7
8
# File 'lib/kleisli/either.rb', line 6

def right
  @right
end

Instance Method Details

#*(other) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/kleisli/either.rb', line 12

def *(other)
  self >-> f {
    other >-> val {
      Right(f.arity > 1 ? f.curry.call(val) : f.call(val))
    }
  }
end

#==(other) ⇒ Object



8
9
10
# File 'lib/kleisli/either.rb', line 8

def ==(other)
  right == other.right && left == other.left
end