Module: RFunk

Defined in:
lib/rfunk/lazy.rb,
lib/rfunk/tuple.rb,
lib/rfunk/version.rb,
lib/rfunk/maybe/none.rb,
lib/rfunk/maybe/some.rb,
lib/rfunk/maybe/option.rb,
lib/rfunk/either/either.rb,
lib/rfunk/either/failure.rb,
lib/rfunk/either/success.rb,
lib/rfunk/attribute/function.rb,
lib/rfunk/attribute/attribute.rb,
lib/rfunk/attribute/immutable.rb,
lib/rfunk/attribute/attribute_type.rb,
lib/rfunk/attribute/error_checking.rb,
lib/rfunk/attribute/assertion_error.rb,
lib/rfunk/attribute/immutable_error.rb,
lib/rfunk/attribute/not_found_error.rb,
lib/rfunk/attribute/attribute_function.rb,
lib/rfunk/attribute/attribute_variable.rb,
lib/rfunk/attribute/pre_condition_error.rb,
lib/rfunk/attribute/attribute_definition.rb,
lib/rfunk/attribute/post_condition_error.rb

Defined Under Namespace

Modules: Attribute, AttributeDefinition, AttributeFunction Classes: AssertionError, AttributeType, AttributeVariable, Either, ErrorChecking, Failure, Function, Immutable, ImmutableError, Lazy, None, NotFoundError, Option, PostConditionError, PreConditionError, Some, Success, Tuple

Constant Summary collapse

VERSION =
'0.9.0'

Instance Method Summary collapse

Instance Method Details

#Either(value) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rfunk/either/either.rb', line 25

def Either(value)
  if lambda?(value)
    either_with_lambda(value)
  else
    either_with_value(value)
  end
end

#Failure(value) ⇒ Object



16
17
18
# File 'lib/rfunk/either/failure.rb', line 16

def Failure(value)
  Failure.new(value)
end

#Lazy(lambda) ⇒ Object



24
25
26
# File 'lib/rfunk/lazy.rb', line 24

def Lazy(lambda)
  Lazy.new(lambda)
end

#None(value = nil) ⇒ Object



40
41
42
# File 'lib/rfunk/maybe/none.rb', line 40

def None(value = nil)
  Option(value)
end

#Option(value) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rfunk/maybe/option.rb', line 12

def Option(value)
  if [Some, None].map { |t| value.is_a?(t) }.any?
    value
  elsif nothing?(value)
    None.instance
  else
    Some.new(value)
  end
end

#Some(value) ⇒ Object



50
51
52
# File 'lib/rfunk/maybe/some.rb', line 50

def Some(value)
  Option(value)
end

#Success(value) ⇒ Object



16
17
18
# File 'lib/rfunk/either/success.rb', line 16

def Success(value)
  Success.new(value)
end

#Tuple(*values) ⇒ Object



25
26
27
# File 'lib/rfunk/tuple.rb', line 25

def Tuple(*values)
  Tuple.new(values)
end