Class: Dhall::TypeChecker::TextLiteral

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/typecheck.rb

Defined Under Namespace

Classes: Chunks

Instance Method Summary collapse

Constructor Details

#initialize(lit) ⇒ TextLiteral



125
126
127
# File 'lib/dhall/typecheck.rb', line 125

def initialize(lit)
  @lit = lit
end

Instance Method Details

#annotate(context) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/dhall/typecheck.rb', line 149

def annotate(context)
  chunks = Chunks.new(@lit.chunks).map { |c|
    TypeChecker.for(c).annotate(context).tap do |annotated|
      TypeChecker.assert annotated.type, Builtins[:Text],
                         "Cannot interpolate #{annotated.type}"
    end
  }.to_a

  Dhall::TypeAnnotation.new(
    value: @lit.with(chunks: chunks),
    type:  Builtins[:Text]
  )
end