Frontend.Promotion
module UnsizedType = Middle.UnsizedType
type t =
| NoPromotion
| IntToReal
| ToVar
| ToComplexVar
| IntToComplex
| RealToComplex
| TuplePromotion of t list
Type to represent promotions in the typechecker. This can be used to return information about how to promote expressions for use in Ast.Promotion
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val scalarize : UnsizedType.t -> UnsizedType.t
Our promotion nodes only store the scalar type to promote, e.g to promote a tuple(array int)
to a tuple(array real)
, we store tuple(real)
, not tuple(array real)
val promote_unsized_type :
UnsizedType.t ->
UnsizedType.autodifftype ->
t ->
UnsizedType.t * UnsizedType.autodifftype
Get the UnsizedType.t
which is the result of promoting a given type. See promote
for the version which promotes expressions directly.
val promote_inner :
Ast.typed_expression ->
t ->
(Ast.typed_expr_meta, Ast.fun_kind) Ast.expr_with
val promote :
(Ast.typed_expr_meta, Ast.fun_kind) Ast.expr_with ->
t ->
(Ast.typed_expr_meta, Ast.fun_kind) Ast.expr_with
val promote_list :
(Ast.typed_expr_meta, Ast.fun_kind) Ast.expr_with list ->
t list ->
(Ast.typed_expr_meta, Ast.fun_kind) Ast.expr_with list
val get_type_promotion_exn :
(UnsizedType.autodifftype * UnsizedType.t) ->
(UnsizedType.autodifftype * UnsizedType.t) ->
t
Get the promotion needed to make the second type into the first. Types NEED to have previously been checked to be promotable or else a fatal error will be thrown.
val promotion_cost : t -> Core.Int.t
Calculate the "cost"/number of promotions performed. Used to disambiguate function signatures