我将如何为下面的代码片段应用类型注释?注意:e 和 r 是列表树的。
let
{--what is the type annotation here for the tuple (e, r)?--}
( e, r ) = List.partition (\(Node a _) -> a == (toString c)) lt
in....
Run Code Online (Sandbox Code Playgroud)
您拥有的是一个解构语句,并且不能有类型注释。
类型注释用于命名函数或值。例如:
plus : Int -> Int -> Int
plus = (+)
year : Int
year = 2017
Run Code Online (Sandbox Code Playgroud)
您的解构(e, r)不是命名函数。它只是向作用域引入了两个新值,e以及r。
| 归档时间: |
|
| 查看次数: |
200 次 |
| 最近记录: |