functional-programmingocamlcamlp4

What does `[< >]` mean in OCaml?


I have seen some source code having

let rec parse_document = parser
    | [< len = parse_int32; st; >] ->
      parse_list [] (ES.take_int32 len st)
    | [< >] -> malformed "parse_document"

Can I know what is [< >] inside? it is too hard to google about this kind of signs.


Solution

  • This is a syntactic sugar for the Stream datatype. Its manipulation is described in detail in this chapter of the book Developping Applications with OCaml.

    The syntactic sugar is not built-in in the compiler, it needs to be preprocessed by the Camlp4 preprocessor. To do that, you have to add -pp camlp4o to your compilation command line.