14 |
|
|
15 |
structure PT = ParseTree |
structure PT = ParseTree |
16 |
structure Ty = Types |
structure Ty = Types |
17 |
|
structure TU = TypeUtil |
18 |
structure U = Util |
structure U = Util |
19 |
|
|
20 |
exception Error |
exception Error |
38 |
fun tok2str (S s) = s |
fun tok2str (S s) = s |
39 |
| tok2str (A a) = Atom.toString a |
| tok2str (A a) = Atom.toString a |
40 |
| tok2str (V x) = Var.nameOf x |
| tok2str (V x) = Var.nameOf x |
41 |
| tok2str (TY ty) = TypeUtil.toString ty |
| tok2str (TY ty) = TU.toString ty |
42 |
| tok2str (TYS []) = "()" |
| tok2str (TYS []) = "()" |
43 |
| tok2str (TYS[ty]) = TypeUtil.toString ty |
| tok2str (TYS[ty]) = TU.toString ty |
44 |
| tok2str (TYS tys) = String.concat[ |
| tok2str (TYS tys) = String.concat[ |
45 |
"(", String.concatWith " * " (List.map TypeUtil.toString tys), ")" |
"(", String.concatWith " * " (List.map TU.toString tys), ")" |
46 |
] |
] |
47 |
in |
in |
48 |
error(cxt, List.map tok2str toks) |
error(cxt, List.map tok2str toks) |
215 |
| PT.E_Cons args => let |
| PT.E_Cons args => let |
216 |
val (args, ty::tys) = checkExprList (env, cxt, args) |
val (args, ty::tys) = checkExprList (env, cxt, args) |
217 |
in |
in |
218 |
case Util.prune ty |
case TU.pruneHead ty |
219 |
of Ty.T_Tensor shape => let |
of Ty.T_Tensor shape => let |
220 |
fun chkTy ty' = U.matchType(ty, ty') |
fun chkTy ty' = U.matchType(ty, ty') |
221 |
val resTy = Ty.T_Tensor(Ty.shapeExt(shape, Ty.DimConst(List.length args))) |
val resTy = Ty.T_Tensor(Ty.shapeExt(shape, Ty.DimConst(List.length args))) |