F# 错误消息";要定义类型,请选择一个或多个…“;

F# 错误消息";要定义类型,请选择一个或多个…“;,f#,F#,我正在学习F#,我从另一个人那里得到了一些代码。 但是当我试图编译代码时,出现了一个错误。 完整代码如下所示: module touchdev_ast open FParsec type Name = string type Operator = | Plus | Minus | Slash | Asterisk | LessOrEqual | Less | Equal | Unequal | GreaterOrEqual | Greater | Assignment // := | And |

我正在学习F#,我从另一个人那里得到了一些代码。 但是当我试图编译代码时,出现了一个错误。 完整代码如下所示:

module touchdev_ast
open FParsec
type Name = string
type Operator =
| Plus | Minus | Slash | Asterisk
| LessOrEqual | Less | Equal | Unequal | GreaterOrEqual | Greater
| Assignment // :=
| And | Or | Not
| Arrow // −>
| Concat // ||

type Parameter = Name (*param name*) * Name (*type qualifier*)
此处(下一行)发生错误

type Expression =
public
| Nothing
| Float of float
| Boolean of bool
| Variable of string
| String of string
| BinaryOperation of Operator * Expression * Expression
| FunctionCall of Name (*fun name*) * Expression list (*arguments*)

and Statement =
public
| Block of Statement list
| Expression of Expression
| Assignment of Expression list (*multiple assignment*) * Expression
| If of Expression * Statement (*then*) * Statement option (*else*)
| ForI of Name (*loop variant*) * Expression (*upper bound*) * Statement
| ForEach of Name (*iterator*) * Expression (*collection*) * Expression option (*condition*) * Statement
| While of Expression * Statement
| MetaStatement of Name

and public FunctionType =
Name (*fun name*) * Parameter list option (*input values*)* Parameter list option (*return values*) * Statement

and TopLevel =
public
| MetaDeclaration of Name (*type*) * string (*value*)
| Action of FunctionType
| Event of FunctionType
| Global of Parameter * Statement (*options*)

type CodeEntry =
public
| Namespace of string (* name *) * bool (* singleton *) * CodeEntry list option (* properties *) * string option (* help *)
| Property of string (* name *) * bool (* public *) * Parameter list option (* input *) * Parameter list option (* return values *) * string option (* help *)
| Variable of string (* name *) * bool (* assignable *) * bool (* initialized *) * string (* type *) * string option (* help *)
| BinaryOperator of string (* name *) * string (* type left *) * string (* type right *) * string (* type return *) * string option (* help *)
| Meta of string (* name *) * string (* value *)
请帮我修复这个错误!!:D
提前谢谢

缩进在F#中很重要,因此需要缩进所声明的每个联合类型的大小写声明。此外,您不需要使用
public
修饰符,因为案例在默认情况下是公共的(尽管这与您的bug无关)


缩进在F#中很重要,因此需要缩进所声明的每个联合类型的大小写声明。此外,您不需要使用
public
修饰符,因为案例在默认情况下是公共的(尽管这与您的bug无关)

module touchdev_ast
open FParsec
type Name = string
type Operator =
    | Plus | Minus | Slash | Asterisk
    | LessOrEqual | Less | Equal | Unequal | GreaterOrEqual | Greater
    | Assignment // :=
    | And | Or | Not
    | Arrow // −>
    | Concat // ||

type Parameter = Name (*param name*) * Name (*type qualifier*)

type Expression =
    | Nothing
    | Float of float
    | Boolean of bool
    | Variable of string
    | String of string
    | BinaryOperation of Operator * Expression * Expression
    | FunctionCall of Name (*fun name*) * Expression list (*arguments*)

and Statement =
    | Block of Statement list
    | Expression of Expression
    | Assignment of Expression list (*multiple assignment*) * Expression
    | If of Expression * Statement (*then*) * Statement option (*else*)
    | ForI of Name (*loop variant*) * Expression (*upper bound*) * Statement
    | ForEach of Name (*iterator*) * Expression (*collection*) * Expression option (*condition*) * Statement
    | While of Expression * Statement
    | MetaStatement of Name

and public FunctionType =
    Name (*fun name*) * Parameter list option (*input values*)* Parameter list option (*return values*) * Statement

and TopLevel =
    | MetaDeclaration of Name (*type*) * string (*value*)
    | Action of FunctionType
    | Event of FunctionType
    | Global of Parameter * Statement (*options*)

type CodeEntry =
    | Namespace of string (* name *) * bool (* singleton *) * CodeEntry list option (* properties *) * string option (* help *)
    | Property of string (* name *) * bool (* public *) * Parameter list option (* input *) * Parameter list option (* return values *) * string option (* help *)
    | Variable of string (* name *) * bool (* assignable *) * bool (* initialized *) * string (* type *) * string option (* help *)
    | BinaryOperator of string (* name *) * string (* type left *) * string (* type right *) * string (* type return *) * string option (* help *)
    | Meta of string (* name *) * string (* value *)