有没有更惯用的方法来对记录进行模式匹配?我的代码似乎不正确。
type Period = AM | PM
type TimeOfDay = {hours : int; minutes : int; p : Period}
let before (tod1 : TimeOfDay, tod2 : TimeOfDay) =
match tod1, tod2 with
| {hours = h1; minutes = m1; p = AM}, {hours = h2; minutes = m2; p = AM} -> (h1, m1) < (h2, m2)
| {hours = h1; minutes = m1; p = PM}, {hours = h2; minutes = m2; p = PM} -> (h1, m1) < (h2, m2)
| {hours = _; minutes = _; p = AM}, {hours = _; minutes = _; p = PM} -> true
| {hours = _; minutes = _; p = PM}, {hours = _; minutes = _; p = AM} -> false