1
我正在嘗試使用as-pattern來分解元組值,並觀察一些奇怪的解析/鍵入行爲。例如FSI(4.0)運行:在F中解析/鍵入as-patterns#
> let t = (0, (1, 2), 3) in let (_, (_, _) as pair, _) = t in();;
let t = (0, (1, 2), 3) in let (_, (_, _) as pair, _) = t in();;
-------------------------------------------------------^
stdin(9,56): error FS0001: Type mismatch. Expecting a
('a * ('b * 'c)) * 'd
but given a
int * (int * int) * int
The type ''a * ('b * 'c)' does not match the type 'int'
然而,例如工作,如果我把一些額外的():
> let t = (0, (1, 2), 3) in let (_, ((_, _) as pair), _) = t in();;
val it : unit =()
這是我稍微愚蠢,或者是解析器在第一失常例?我猜想它試圖將「as pair」應用於「,(,_)」,這看起來稍微比看起來更加貪婪。