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, #included_into

Methods included from MatcherDelegations

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

Methods included from Matching

#any, match_value, #on

Methods included from TypeCheck

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

Constructor Details

- (Type) initialize(name, &definition)

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

- (Object) ==(other)

Raises:

  • (NotImplementedError)


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

def ==(other)
  raise NotImplementedError
end

- (Object) be_kind_of(type)

Raises:

  • (NotImplementedError)


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

def be_kind_of(type)
  raise NotImplementedError
end

- (Object) inspect



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

def inspect
  to_s
end

- (Object) match(value, *cases)



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

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

- (Object) name



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

def name
  super || @name || 'NoName'
end

- (Object) to_m(*args)

Raises:

  • (NotImplementedError)


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

def to_m(*args)
  raise NotImplementedError
end

- (Object) to_s

Raises:

  • (NotImplementedError)


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

def to_s
  raise NotImplementedError
end