Module: RFunk

Defined in:
lib/rfunk/lazy.rb,
lib/rfunk/match.rb,
lib/rfunk/tuple.rb,
lib/rfunk/version.rb,
lib/rfunk/maybe/none.rb,
lib/rfunk/maybe/some.rb,
lib/rfunk/match/error.rb,
lib/rfunk/maybe/option.rb,
lib/rfunk/either/either.rb,
lib/rfunk/match/pattern.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/type_annotation.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, Match Classes: AssertionError, AttributeType, AttributeVariable, Either, ErrorChecking, Failure, Function, Immutable, ImmutableError, Lazy, None, NotFoundError, Option, PostConditionError, PreConditionError, Some, Success, Tuple, TypeAnnotation

Constant Summary collapse

VERSION =
'2.1.0'.freeze

Class Method Summary collapse

Class Method Details

.either(value) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/rfunk/either/either.rb', line 28

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

.failure(value) ⇒ Object


21
22
23
# File 'lib/rfunk/either/failure.rb', line 21

def failure(value)
  RFunk::Failure.new(value)
end

.lazy(lambda) ⇒ Object


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

def lazy(lambda)
  RFunk::Lazy.new(lambda)
end

.noneObject


65
66
67
# File 'lib/rfunk/maybe/none.rb', line 65

def none
  RFunk::None.instance
end

.option(value) ⇒ Object


19
20
21
22
23
# File 'lib/rfunk/maybe/option.rb', line 19

def option(value)
  return value if RFunk::Option.descendants.map { |t| value.is_a?(t) }.any?

  RFunk::Option.descendants.find { |c| c.satisfies?(value) }.create(value)
end

.some(value) ⇒ Object


69
70
71
# File 'lib/rfunk/maybe/some.rb', line 69

def some(value)
  RFunk.option(value)
end

.success(value) ⇒ Object


21
22
23
# File 'lib/rfunk/either/success.rb', line 21

def success(value)
  RFunk::Success.new(value)
end

.tuple(*values) ⇒ Object


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

def tuple(*values)
  RFunk::Tuple.new(values)
end