class Dhall::TypeChecker::RecordProjection

Public Class Methods

new(projection) click to toggle source
# File lib/dhall/typecheck.rb, line 635
def initialize(projection)
        @projection = projection
        @record = TypeChecker.for(projection.record)
        @selectors = projection.selectors
end

Public Instance Methods

annotate(context) click to toggle source
# File lib/dhall/typecheck.rb, line 641
def annotate(context)
        arecord = @record.annotate(context)

        TypeChecker.assert arecord.type.class.name, "Dhall::RecordType",
                           "RecordProjection on #{arecord.type}"

        slice = arecord.type.slice(@selectors)
        TypeChecker.assert slice.keys, @selectors,
                           "#{arecord.type} missing one of: #{@selectors}"

        Dhall::TypeAnnotation.new(
                value: @projection.with(record: arecord),
                type:  slice
        )
end