|
@ -319,10 +319,17 @@ function checkName(exp) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function DataType(params, type) { |
|
|
function DataType(name, params, type) { |
|
|
/* Params is a list of type variables |
|
|
/* Params is a list of type variables |
|
|
* type is a type expression |
|
|
* type is a type expression |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
if (name.exprType !== "TypeOperator") { |
|
|
|
|
|
throw errors.JSyntaxError( |
|
|
|
|
|
name.linenum, |
|
|
|
|
|
name.charnum, |
|
|
|
|
|
"First element in a data type definition must be its name " + |
|
|
|
|
|
"which is a type operator"); |
|
|
|
|
|
} |
|
|
_.each(params, checkName); |
|
|
_.each(params, checkName); |
|
|
if (!isTypeExprRec(type)) { |
|
|
if (!isTypeExprRec(type)) { |
|
|
throw errors.JSyntaxError( |
|
|
throw errors.JSyntaxError( |
|
@ -330,6 +337,7 @@ function DataType(params, type) { |
|
|
type.charnum, |
|
|
type.charnum, |
|
|
"Body of a type definition must be a valid type expression"); |
|
|
"Body of a type definition must be a valid type expression"); |
|
|
} |
|
|
} |
|
|
|
|
|
this.name = name; |
|
|
this.params = params; |
|
|
this.params = params; |
|
|
this.type = type; |
|
|
this.type = type; |
|
|
this.exprType = "TypeFuncDefinition"; |
|
|
this.exprType = "TypeFuncDefinition"; |
|
|