Module: Functional
- Defined in:
- lib/functional.rb,
lib/functional/memo.rb,
lib/functional/delay.rb,
lib/functional/union.rb,
lib/functional/either.rb,
lib/functional/option.rb,
lib/functional/record.rb,
lib/functional/version.rb,
lib/functional/protocol.rb,
lib/functional/type_check.rb,
lib/functional/protocol_info.rb,
lib/functional/abstract_struct.rb,
lib/functional/method_signature.rb,
lib/functional/pattern_matching.rb
Overview
Erlang, Clojure, and Go inspired functional programming tools to Ruby.
Defined Under Namespace
Modules: AbstractStruct, Memo, PatternMatching, Protocol, Record, TypeCheck, Union Classes: Delay, Either, Option, ProtocolInfo
Constant Summary collapse
- Infinity =
Infinity
1/0.0
- NaN =
Not a number
0/0.0
- VERSION =
The current gem version.
'1.0.0'- ProtocolError =
An exception indicating a problem during protocol processing.
Class.new(StandardError)
Class Method Summary collapse
-
.configure {|the| ... } ⇒ Object
Perform gem-level configuration.
-
.SpecifyProtocol(name) { ... } ⇒ Functional::ProtocolInfo
Specify a new protocol or retrieve the specification of an existing protocol.
Class Method Details
.configure {|the| ... } ⇒ Object
Perform gem-level configuration.
53 54 55 |
# File 'lib/functional.rb', line 53 def self.configure yield(configuration) end |
.SpecifyProtocol(name) { ... } ⇒ Functional::ProtocolInfo
Specify a new protocol or retrieve the specification of an existing protocol.
When called without a block the global protocol registry will be searched for a protocol with the matching name. If found the corresponding ProtocolInfo object will be returned. If not found nil will be returned.
When called with a block, a new protocol with the given name will be created and the block will be processed to provide the specifiction. When successful the new ProtocolInfo object will be returned. An exception will be raised if a protocol with the same name already exists.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/functional/protocol.rb', line 38 def SpecifyProtocol(name, &block) name = name.to_sym protocol_info = Protocol.class_variable_get(:@@info)[name] return protocol_info unless block_given? if block_given? && protocol_info raise ProtocolError.new(":#{name} has already been defined") end info = ProtocolInfo.new(name, &block) Protocol.class_variable_get(:@@info)[name] = info end |