F# 我希望函数返回bool,但是;此表达式的类型应为';int*int*string';但是这里有类型';字符串'&引用;

F# 我希望函数返回bool,但是;此表达式的类型应为';int*int*string';但是这里有类型';字符串'&引用;,f#,tuples,F#,Tuples,我自己解决这个问题,四个小时后,我接近完成第3.1.1部分,但无法解释为什么我不能让它返回布尔值,特别是因为类似的函数乐于进行字符串连接 (* 3.1 A time of day can be represented as a triple (hours, minutes, f) where f is either AM or PM – or as a record. Declare a function to test whether one time of day comes be

我自己解决这个问题,四个小时后,我接近完成第3.1.1部分,但无法解释为什么我不能让它返回布尔值,特别是因为类似的函数乐于进行字符串连接

(*
3.1 A time of day can be represented as a 
triple (hours, minutes, f) 
where f is either AM or PM – or as a record. 

Declare a function to test whether one time of day comes 
before another. 

For example, (11,59,"AM") comes before (1,15,"PM"). 

Make solutions with triples as well as with records. 

Declare the functions in infix notation.

Hansen, Michael R.; Rischel, Hans. 
Functional Programming Using F# (p. 66). 
Cambridge University Press. Kindle Edition. 
*)

type TimeOfDayTriple = int * int * string

let (<.) ((hour1, min1, pod1):TimeOfDayTriple) ((hour2, min2, pod2):TimeOfDayTriple) =
    true
//val ( <. ) : int * int * string -> int * int * string -> bool

let (<.) ((hour1, min1, pod1):TimeOfDayTriple) ((hour2, min2, pod2):TimeOfDayTriple) =
    (pod1, pod2)
//val ( <. ) : int * int * string -> int * int * string -> string * string

let (<.) ((hour1, min1, pod1):TimeOfDayTriple) ((hour2, min2, pod2):TimeOfDayTriple) =
    pod1 + pod2
val ( <. ) : int * int * string -> int * int * string -> string
    
let (<.) ((hour1, min1, pod1):TimeOfDayTriple) ((hour2, min2, pod2):TimeOfDayTriple) =
    pod1 < pod2;;
//Ch03.fsx(32,5): error FS0001: This expression was expected to have type
//    'int * int * string'    
//but here has type
//    'string'    
(*
3.1一天中的某个时间可以表示为
三倍(小时、分钟、f)
其中f为AM或PM–或作为记录。
声明一个函数以测试一天中是否有一个时间
在另一个之前。
例如,(11,59,“AM”)在(1,15,“PM”)之前。
用三元组和记录制作解决方案。
用中缀表示法声明函数。
汉森,迈克尔R;瑞舍尔,汉斯。
使用F#的函数式编程(第66页)。
剑桥大学出版社,Kindle版。
*)
类型timeOfDaytree=int*int*string
让(布尔)
让(字符串*字符串)
让(串)

let(如注释中所述,如果您意外地重新定义了注释中所述的
,则可能会出现此错误;如果您意外地重新定义了
,则可能会出现此错误(我做了。然后我尝试撤消它,但很有可能我没有成功地清除环境。在fsx脚本模式下,有没有办法在不关闭VisualStudio的情况下清除REPL环境?我想你右键单击并提供了重新启动或重设的选项我做了。然后我尝试撤消它,但很有可能我没有成功正在清除环境。在fsx脚本模式下,有没有一种方法可以在不关闭VisualStudio的情况下清除REPL环境?我想您可以右键单击,然后出现一个重新启动或重置选项
[<CustomComparison>]
type TimeOfDayTriple = 
  | TOD of int * int * string
  interface System.IComparable<TimeOfDayTriple> with
    member x.CompareTo(TOD(h2, m2, p2)) =
      let (TOD(h1, m1, p1)) = x
      // (implement comparison here)