Class: Dhall::TypeChecker::Union
- Inherits:
-
Object
- Object
- Dhall::TypeChecker::Union
- Defined in:
- lib/dhall/typecheck.rb
Instance Method Summary collapse
- #annotate(context) ⇒ Object
-
#initialize(union) ⇒ Union
constructor
A new instance of Union.
Constructor Details
#initialize(union) ⇒ Union
667 668 669 670 |
# File 'lib/dhall/typecheck.rb', line 667 def initialize(union) @union = union @value = TypeChecker.for(union.value) end |
Instance Method Details
#annotate(context) ⇒ Object
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/dhall/typecheck.rb', line 672 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 |