OCaml错误:"变体类型没有构造函数::"

时间:2015-10-09 13:29:57

标签: constructor ocaml ml

我现在正在研究OCaml,在我这样做之后,

type aexp =
| Const of int
| Var of string
| Power of string * int
| Times of aexp list
| Sum of aexp list

let rec diff : aexp * string -> aexp
=fun (aexp,x) -> match aexp with
|Const a -> Const 0
|Var "x" -> Const 1
|Power ("x", a) -> (match a with
 |2 -> Times[Const 2; Var "x"]
 |1 -> Const 1
 |0 -> Const 0
 |_ -> Times[Const a; Power ("x", a-1)])
|Times [l] -> (match l with
 |h::t -> (match t with
  |Var "x" -> h
  |Power ("x",a) -> Times [Times [h;Const a];diff(Power ("x",a),x)]))

我收到错误:

  

文件"",第11行,字符3-5:

     

错误:变体类型aexp没有构造函数::

我了解到::是单个元素与列表或列表中其他元素的串联。

它与我使用列表的其他代码一起使用。

为什么它不在这里工作?

0 个答案:

没有答案