我正在处理一个无法修改的旧数据库。由于类型提供程序,我决定使用F#。现在我已经深入其中,但事情并不那么简单。我如何为我的数据库中只有以下字符串的字段结构化呢?它有点像枚举类型。我尝试了以下方法,但还没有完全搞清楚。
尝试1
type SuspendedDriver = "SI"
type ActiveDriver = "IMPRESO"
type Applicant = "NO"
type TemporaryDriver = "TEMP"
type Uncertain = "NULL"
type DriverStatus =
| SuspendedDriver
| ActiveDriver
| Applicant
| TemporaryDriver
| Uncertain
type Driver = {
status : DriverStatus
}
错误
Error FS0618: Invalid literal in type (FS0618) (ScriptTest)
第二次尝试
type DriverStatus =
| SuspendedDriver = "SI"
| ActiveDriver = "IMPRESO"
| Applicant = "NO"
| TemporaryDriver = "TEMP"
| Uncertain = "NULL"
错误
Error FS0951: Literal enumerations must have type int, uint, int16,
uint16, int64, uint64, byte, sbyte or char (FS0951) (ScriptTest)