This operator is commonly used to give code a dataflow structure. Since 4.01 this is included in standard OCaml.
Everything converts to and from an Enum, an efficient enumeration type.
Instead of a
for loop with body
f:int -> unit, one can write
(1--n) |> iter f.
To convert between a
List and a
List.enum lst |> Set.of_enum.
General purpose Input/Output channels
Same as http://ocaml.janestcapital.com/?q=node/91 but with slightly different names.
Data structure modules provide a
Printf.printf like this:
Printf.printf "Int is: %a" Int.print 5
This is pretty boring, until you realize that polymorphic containers'
Printf.printf "Pair: %a, List:%a\n" (Pair.print String.print Float.print) ("abc",3.14) (List.print Int.print) [3;4;5]