~singpolyma/dhall-ruby

287dfd1f0303dec64413cd0832a78c7d9b7c7c2f — Stephen Paul Weber 5 years ago 1efcc58
Finish merge refactor
1 files changed, 13 insertions(+), 11 deletions(-)

M lib/dhall/typecheck.rb
M lib/dhall/typecheck.rb => lib/dhall/typecheck.rb +13 -11
@@ 685,6 685,8 @@ module Dhall

					TypeChecker.assert @union.type, Dhall::UnionType,
					                   "Merge expected Union got: #{@union.type}"

					assert_union_and_handlers_match
				end

				def annotation


@@ 698,8 700,16 @@ module Dhall
					@type ||= @handlers.output_type(@merge.type)
				end

				def kind(context)
					TypeChecker.for(type).annotate(context).type
				def assert_kind(context)
					kind = TypeChecker.for(type).annotate(context).type

					TypeChecker.assert(
						kind,
						Dhall::Variable["Type"],
						"Merge must have kind Type"
					)

					kind
				end

				def assert_union_and_handlers_match


@@ 723,15 733,7 @@ module Dhall
					record: @record.annotate(context),
					input:  @union.annotate(context)
				)

				amerge.assert_union_and_handlers_match

				TypeChecker.assert(
					amerge.kind(context),
					Dhall::Variable["Type"],
					"Merge must have kind Type"
				)

				amerge.assert_kind(context)
				amerge.annotation
			end
		end