Is it possible to use pipes in OCaml?

前端 未结 1 1600
独厮守ぢ
独厮守ぢ 2021-02-18 20:20

In F# I can\'t live without pipes (<| and |>)

let console(dashboard : Dashboard ref) = 
    let rec eat (command : string) =
             


        
1条回答
  •  时光说笑
    2021-02-18 21:04

    These are available since OCaml 4.01. However, <| is named @@ there, so it has the correct operator associativity.

    Alternatively, you can either define them yourself:

    let (|>) v f = f v
    let (<|) f v = f v  (* or: *)
    let (@@) f v = f v
    

    Or you use Ocaml batteries included, which has the |> and <| operators defined in BatStd.

    0 讨论(0)
提交回复
热议问题