I'm converting some F# code to OCaml and I see a lot of uses of this pipeline operator <|
, for example:
let printPeg expr =
printfn "%s" <| pegToString expr
The <|
operator is apparently defined as just:
# let ( <| ) a b = a b ;;
val ( <| ) : ('a -> 'b) -> 'a -> 'b = <fun>
I'm wondering why they bother to define and use this operator in F#, is it just so they can avoid putting in parens like this?:
let printPeg expr =
Printf.printf "%s" ( pegToString expr )
As far as I can tell, that would be the conversion of the F# code above to OCaml, correct?
Also, how would I implement F#'s <<
and >>
operators in Ocaml?
( the |>
operator seems to simply be: let ( |> ) a b = b a ;;
)