Class: Algebrick::Type

Inherits:
Module
  • Object
show all
Includes:
MatcherDelegations, Matching, Reclude, TypeCheck
Defined in:
lib/algebrick/type.rb

Overview

Any Algebraic type defined by Algebrick is kind of Type

Direct Known Subclasses

Atom, ParametrizedType, ProductVariant

Instance Method Summary collapse

Methods included from Reclude

#include, #included

Methods included from MatcherDelegations

#!, #&, #>, #>>, #case, #|, #~

Methods included from Matching

#any, #match?, #on

Methods included from TypeCheck

#Child!, #Child?, #Match!, #Match?, #Type!, #Type?

Constructor Details

#initialize(name, &definition) ⇒ Type

Returns a new instance of Type.



23
24
25
26
# File 'lib/algebrick/type.rb', line 23

def initialize(name, &definition)
  super &definition
  @name = name
end

Instance Method Details

#==(other) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/algebrick/type.rb', line 36

def ==(other)
  raise NotImplementedError
end

#be_kind_of(type) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/algebrick/type.rb', line 40

def be_kind_of(type)
  raise NotImplementedError
end

#inspectObject



48
49
50
# File 'lib/algebrick/type.rb', line 48

def inspect
  to_s
end

#match(value, *cases) ⇒ Object



52
53
54
55
# File 'lib/algebrick/type.rb', line 52

def match(value, *cases)
  Type! value, self
  super value, *cases
end

#nameObject



28
29
30
# File 'lib/algebrick/type.rb', line 28

def name
  super || @name || nil
end

#to_m(*args) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/algebrick/type.rb', line 32

def to_m(*args)
  raise NotImplementedError
end

#to_sObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/algebrick/type.rb', line 44

def to_s
  raise NotImplementedError
end