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

Returns a new instance of TextLiteral.



121
122
123
# File 'lib/dhall/typecheck.rb', line 121

def initialize(lit)
  @lit = lit
end

Instance Method Details

#annotate(context) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/dhall/typecheck.rb', line 145

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