Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 361
Jackson Tale Avatar asked Apr 22 '13 14:04

Jackson Tale


1 Answers

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.

like image 98
gasche Avatar answered Oct 10 '22 00:10

gasche