Module Frontend.Promotion

module UnsizedType = Middle.UnsizedType
type t =
  1. | NoPromotion
  2. | IntToReal
  3. | ToVar
  4. | ToComplexVar
  5. | IntToComplex
  6. | RealToComplex
  7. | 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)

Get the UnsizedType.t which is the result of promoting a given type. See promote for the version which promotes expressions directly.

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