class Dhall::TypeChecker::Union

Public Class Methods

new(union) click to toggle source
# File lib/dhall/typecheck.rb, line 707
def initialize(union)
        @union = union
        @value = TypeChecker.for(union.value)
end

Public Instance Methods

annotate(context) click to toggle source
# File lib/dhall/typecheck.rb, line 712
def annotate(context)
        annotated_value = @value.annotate(context)

        type = Dhall::UnionType.new(
                alternatives: { @union.tag => annotated_value.type }
        ).merge(@union.alternatives)

        # Annotate to sanity check
        TypeChecker.for(type).annotate(context)

        Dhall::TypeAnnotation.new(
                value: @union.with(value: annotated_value),
                type:  type
        )
end