如何命名F#函数声明的参数

Dax*_*ohl 3 f#

如果我有一个包含所有数据库函数的记录类型

type Database =
  { getThingsByCountThenLength: int -> int -> Thing list
    getUsersByFirstNameThenLastName: string -> string -> User list }
Run Code Online (Sandbox Code Playgroud)

有没有办法命名输入参数,所以它更清楚?像下面的东西(不编译)

type Database =
  { getThings: count:int -> length:int -> Thing list
    getUsers: firstName:string -> lastName:string -> User list }
Run Code Online (Sandbox Code Playgroud)

(注意它确实适用于接口;我只是想要它用于记录.)

type IDatabase =
  abstract getThings: count:int -> length:int -> Thing list
  abstract getUsers: firstName:string -> lastName:string -> User list
Run Code Online (Sandbox Code Playgroud)

lob*_*ism 5

这不是一个直接的答案(我认为没有),但作为替代方案,您可以使用单案例联合类型,这不仅可以增加清晰度并继续允许currying,还可以强制编译时正确性.

type Count = Count of int
type Length = Length of int
type FirstName = FirstName of string
type LastName = LastName of string

type Database =
  { getThings: Count -> Length -> Thing list
    getUsers: FirstName -> LastName -> User list }
Run Code Online (Sandbox Code Playgroud)