class Dhall::TypeChecker::Operator

Public Class Methods

new(expr, type) click to toggle source
# File lib/dhall/typecheck.rb, line 220
def initialize(expr, type)
        @expr = expr
        @lhs = TypeChecker.for(expr.lhs)
        @rhs = TypeChecker.for(expr.rhs)
        @type = type
end

Public Instance Methods

annotate(context) click to toggle source
# File lib/dhall/typecheck.rb, line 227
def annotate(context)
        annotated_lhs = @lhs.annotate(context)
        annotated_rhs = @rhs.annotate(context)
        types = [annotated_lhs.type, annotated_rhs.type]
        if types.any? { |t| t != @type }
                raise TypeError, "Operator arguments not #{@type}: #{types}"
        end

        Dhall::TypeAnnotation.new(
                value: @expr.with(lhs: annotated_lhs, rhs: annotated_rhs),
                type:  @type
        )
end