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.



127
128
129
# File 'lib/dhall/typecheck.rb', line 127

def initialize(lit)
	@lit = lit
end

Instance Method Details

#annotate(context) ⇒ Object



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

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