Class: Jade::Frontend::TypeChecking::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/jade/frontend/type_checking/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints

Returns:

  • (Object)

    the current value of constraints



4
5
6
# File 'lib/jade/frontend/type_checking/result.rb', line 4

def constraints
  @constraints
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/jade/frontend/type_checking/result.rb', line 4

def type
  @type
end

Class Method Details

.accumulatorObject



26
27
28
# File 'lib/jade/frontend/type_checking/result.rb', line 26

def self.accumulator
  ResultAcc[[], []]
end

.init(type, constraints = []) ⇒ Object



5
6
7
# File 'lib/jade/frontend/type_checking/result.rb', line 5

def self.init(type, constraints = [])
  new(type, constraints)
end

Instance Method Details

#apply(substitution) ⇒ Object



9
10
11
12
# File 'lib/jade/frontend/type_checking/result.rb', line 9

def apply(substitution)
  with(type: substitution.apply(type))
    .with(constraints: constraints.map { substitution.apply(it) })
end

#attach_origin(node) ⇒ Object



20
21
22
23
24
# File 'lib/jade/frontend/type_checking/result.rb', line 20

def attach_origin(node)
  constraints
    .map { it.with(origin: node) }
    .then { with(constraints: it) }
end

#map(&block) ⇒ Object



14
15
16
17
18
# File 'lib/jade/frontend/type_checking/result.rb', line 14

def map(&block)
  block
    .call(type)
    .then { with(type: it) }
end