Using Core.Std.List.fold_left without label

前端 未结 2 1286
灰色年华
灰色年华 2021-01-21 08:07

I am experimenting with Core\'s List.fold_left.

# List.fold_left;;
- : \'a Core.Std.List.t -> init:\'b -> f:(\'b -> \'a -> \'b) -> \'         


        
2条回答
  •  太阳男子
    2021-01-21 08:25

    According to the manual you may only omit labels "if an application is total (omitting all optional arguments)" with the important caveat "that functions like ListLabels.fold_left whose result type is a type variable will never be considered as totally applied."

    So since core's fold_left's result type is, of course, also a type variable, you can not call it without labels. What happens when you do is that the positional arguments are interpreted as arguments to the function produced by fold_left and it still waits for you to provide the labeled arguments.

提交回复
热议问题