package ppxlib_jane

  1. Overview
  2. Docs

The ASTs for list and array comprehensions

type iterator =
  1. | Range of {
    1. start : Ppxlib_ast.Parsetree.expression;
    2. stop : Ppxlib_ast.Parsetree.expression;
    3. direction : Ppxlib_ast.Asttypes.direction_flag;
    }
    (*

    "= START to STOP" (direction = Upto) "= START downto STOP" (direction = Downto)

    *)
  2. | In of Ppxlib_ast.Parsetree.expression
    (*

    "in EXPR"

    *)
type clause_binding = {
  1. pattern : Ppxlib_ast.Parsetree.pattern;
  2. iterator : iterator;
  3. attributes : Ppxlib_ast.Parsetree.attribute list;
}

@... PAT (in/=) ...

type clause =
  1. | For of clause_binding list
    (*

    "for PAT (in/=) ... and PAT (in/=) ... and ..."; must be nonempty

    *)
  2. | When of Ppxlib_ast.Parsetree.expression
    (*

    "when EXPR"

    *)
type comprehension = {
  1. body : Ppxlib_ast.Parsetree.expression;
    (*

    The body/generator of the comprehension

    *)
  2. clauses : clause list;
    (*

    The clauses of the comprehension; must be nonempty

    *)
}
type expression =
  1. | Cexp_list_comprehension of comprehension
    (*

    BODY ...CLAUSES...

    *)
  2. | Cexp_array_comprehension of Ppxlib_ast.Asttypes.mutable_flag * comprehension
    (*

    |BODY ...CLAUSES...| (flag = Mutable) :BODY ...CLAUSES...: (flag = Immutable) (only allowed with -extension immutable_arrays)

    *)
OCaml

Innovation. Community. Security.