【发布时间】:2017-05-14 06:24:43
【问题描述】:
根据accepted answer,在 F# 和 OCaml 中,我需要使用下划线来丢弃其余记录。但是,为什么handle' 函数可以工作,而handle 函数却不行呢?
type Type = Type of int
type Entity =
{ type' : Type
foo : string }
let handle entities =
match entities with
| {type' = Type i; _ }::entites -> ()
| [] -> ()
let handle' entities =
match entities with
| {type' = Type i }::entites -> ()
| [] -> ()
【问题讨论】:
-
也许这只是 OCaml 和 F# 之间的不兼容。出于好奇,您是如何得出它应该在 F# 中工作的结论的? (我并不是说不兼容是一件好事;只是说它可能是一件事)。
标签: f# functional-programming pattern-matching ocaml record