class Dhall::TypeChecker::Merge::AnnotatedMerge
Public Class Methods
new(merge:, record:, input:)
click to toggle source
# File lib/dhall/typecheck.rb, line 807 def initialize(merge:, record:, input:) @merge = merge.with(record: record, input: input) @handlers = Handlers.new(record) @record = record @union = input TypeChecker.assert @union.type, Dhall::UnionType, "Merge expected Union got: #{@union.type}" assert_union_and_handlers_match end
Public Instance Methods
annotation()
click to toggle source
# File lib/dhall/typecheck.rb, line 819 def annotation Dhall::TypeAnnotation.new( value: @merge, type: type ) end
assert_kind(context)
click to toggle source
# File lib/dhall/typecheck.rb, line 830 def assert_kind(context) kind = TypeChecker.for(type).annotate(context).type TypeChecker.assert( kind, Builtins[:Type], "Merge must have kind Type" ) kind end
assert_union_and_handlers_match()
click to toggle source
# File lib/dhall/typecheck.rb, line 842 def assert_union_and_handlers_match extras = @handlers.keys ^ @union.type.alternatives.keys TypeChecker.assert extras.to_a, [], "Merge handlers unknown alternatives: #{extras}" @union.type.alternatives.each do |k, atype| atype.nil? || TypeChecker.assert( @handlers.fetch_input_type(k), atype, "Handler argument does not match alternative type: #{atype}" ) end end
type()
click to toggle source
# File lib/dhall/typecheck.rb, line 826 def type @type ||= @handlers.output_type(@merge.type) end