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
Returns a new instance of Union.
707 708 709 710 |
# File 'lib/dhall/typecheck.rb', line 707 def initialize(union) @union = union @value = TypeChecker.for(union.value) end |
Instance Method Details
#annotate(context) ⇒ Object
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# 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 |