class Dhall::TypeChecker::Assertion

Public Class Methods

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

Public Instance Methods

annotate(context) click to toggle source
# File lib/dhall/typecheck.rb, line 1045
def annotate(context)
        TypeChecker.assert @type, Dhall::Operator::Equivalent,
                           "assert expected === got: #{@type.class}"

        TypeChecker.assert_type @type, Builtins[:Type],
                                "=== expected to have type Type",
                                context: context

        TypeChecker.assert @type.lhs.normalize.to_binary,
                           @type.rhs.normalize.to_binary,
                           "assert equivalence not equivalent"

        @expr.with(type: @type.normalize)
end