package ppxlib_jane

  1. Overview
  2. Docs

The ASTs for labeled tuples. When we merge this upstream, we'll replace existing P{typ,exp,pat}_tuple constructors with these.

type core_type = (string option * Ppxlib_ast.Parsetree.core_type) list

tl represents a product type:

  • T1 * ... * Tn when tl is (None,T1);...;(None,Tn)
  • L1:T1 * ... * Ln:Tn when tl is (Some L1,T1);...;(Some Ln,Tn)
  • A mix, e.g. L1:T1,T2 when tl is (Some L1,T1);(None,T2)

Invariant: n >= 2.

type expression = (string option * Ppxlib_ast.Parsetree.expression) list

el represents

  • (E1, ..., En) when el is (None, E1);...;(None, En)
  • (~L1:E1, ..., ~Ln:En) when el is (Some L1, E1);...;(Some Ln, En)
  • A mix, e.g.: (~L1:E1, E2) when el is (Some L1, E1); (None, E2)

Invariant: n >= 2.

type pattern = (string option * Ppxlib_ast.Parsetree.pattern) list * Ppxlib_ast.Asttypes.closed_flag

(pl, Closed) represents

  • (P1, ..., Pn) when pl is (None, P1);...;(None, Pn)
  • (L1:P1, ..., Ln:Pn) when pl is (Some L1, P1);...;(Some Ln, Pn)
  • A mix, e.g. (L1:P1, P2) when pl is (Some L1, P1);(None, P2)
  • If pattern is open, then it also ends in a ..

Invariant:

  • If Closed, n >= 2.
  • If Open, n >= 1.

Embeds the core type in Jane Syntax only if there are any labels. Otherwise, returns a normal Ptyp_tuple.

Embeds the expression in Jane Syntax only if there are any labels. Otherwise, returns a normal Pexp_tuple.

Embeds the pattern in Jane Syntax only if there are any labels or if the pattern is open. Otherwise, returns a normal Ppat_tuple.

OCaml

Innovation. Community. Security.