【发布时间】:2018-11-24 02:16:05
【问题描述】:
我定义了 2 个可区分的联合:“Direction”和“TurnCommand”:
type Direction =
| South of string
| East of string
| North of string
| West of string
type TurnCommand =
| Left of string
| Right of string
然后我在制作 TurnCommand 后定义函数有新的方向:
type Turn = Direction -> TurnCommand -> Direction
这里没有实现这个功能:
let Do:Turn = fun(startDirection) (turn) ->
match startDirection, turn with
| South, Left -> East
| East, Left -> North
| North, Left -> West
| West, Left -> South
| South, Right -> West
| East, Right -> South
| North, Right -> East
| West, Right -> North
有错误:“构造函数应用于 0 个参数,但需要 1 个”。 我知道它需要字符串值,但我需要在这里匹配类型。 谢谢!
【问题讨论】: