(* types.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Internal representation of Diderot types. These are the types produced * by the type checker. *) structure Types = struct (* kinds for type variables *) datatype kind = TK_NAT (* ranges over natural numbers (0, 1, 2, ...) *) | TK_SHAPE (* ranges over tensor shapes *) | TK_TYPE (* ranges over types *) (* raw numeric types as supported by NRRD *) datatype raw_ty = RT_Int8 | RT_UInt8 | RT_Int16 | RT_UInt16 | RT_Int32 | RT_UInt32 | RT_Int64 | RT_UInt64 | RT_Float | RT_Double | RT_Var of var and ty = T_Var of var | T_Bool | T_Int | T_String (* convolution kernel; argument is number of levels of differentiation *) | T_Kernel of nat (* scalars, vectors, matrices, etc.; argument is tensor shape *) | T_Tensor of shape (* data sets from NRRD *) | T_Image of { dim : nat, (* 2D or 3D data set *) shape : shape (* tensor shape; order is length of list *) } (* continuous field reconstructed from a data set *) | T_Field of { diff : nat, (* number of levels of differentiation supported *) dim : nat, (* dimension of domain (2D or 3D field) *) shape : shape (* shape of tensors in range; order is length of list *) } | T_Fun of ty list * ty list and shape = Shape of nat list | ShapeVar of var | ShapeExt of shape * nat (* extension of shape (i.e., for D operator) *) and nat = NatConst of int (* i *) | NatExp of (nat * int) (* d + i; for diff fields only *) | NatVar of var (* type variables; the kind field restricts their range *) and var = TV of { kind : kind, stamp : Stamp.stamp } type scheme = var list * ty (* useful types *) val realTy = T_Tensor(Shape[]) val vec2Ty = T_Tensor(Shape[NatConst 2]) val vec3Ty = T_Tensor(Shape[NatConst 3]) val vec4Ty = T_Tensor(Shape[NatConst 4]) end