Class: Dhall::TypeChecker::If::AnnotatedIf
- Inherits:
-
Object
- Object
- Dhall::TypeChecker::If::AnnotatedIf
- Defined in:
- lib/dhall/typecheck.rb
Instance Method Summary collapse
- #annotation ⇒ Object
-
#initialize(expr, apred, athen, aelse, context:) ⇒ AnnotatedIf
constructor
A new instance of AnnotatedIf.
Constructor Details
#initialize(expr, apred, athen, aelse, context:) ⇒ AnnotatedIf
Returns a new instance of AnnotatedIf.
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/dhall/typecheck.rb', line 177 def initialize(expr, apred, athen, aelse, context:) TypeChecker.assert apred.type, Builtins[:Bool], "If must have a predicate of type Bool" TypeChecker.assert_type athen.type, Builtins[:Type], "If branches must have types of type Type", context: context TypeChecker.assert aelse.type, athen.type, "If branches have mismatched types" @expr = expr.with(predicate: apred, then: athen, else: aelse) end |
Instance Method Details
#annotation ⇒ Object
188 189 190 191 192 193 |
# File 'lib/dhall/typecheck.rb', line 188 def annotation Dhall::TypeAnnotation.new( value: @expr, type: @expr.then.type ) end |