package ocaml-base-compiler

  1. Overview
  2. Docs

Detection of partial matches and unused match cases.

val omega : Typedtree.pattern

aka. "Tpat_any" or "_"

val omegas : int -> Typedtree.pattern list

List.init (fun _ -> omega)

val omega_list : 'a list -> Typedtree.pattern list

List.map (fun _ -> omega)

val normalize_pat : Typedtree.pattern -> Typedtree.pattern

Keep only the "head" of a pattern: all arguments are replaced by omega, so are variables.

val const_compare : Asttypes.constant -> Asttypes.constant -> int

const_compare c1 c2 compares the actual values represented by c1 and c2, while simply using Pervasives.compare would compare the representations.

cf. MPR#5758

val le_pat : Typedtree.pattern -> Typedtree.pattern -> bool

le_pat p q means: forall V, V matches q implies V matches p

val le_pats : Typedtree.pattern list -> Typedtree.pattern list -> bool

le_pats (p1 .. pm) (q1 .. qn) means: forall i <= m, le_pat pi qi

module Compat (Constr : sig ... end) : sig ... end

Exported compatibility functor, abstracted over constructor equality

exception Empty

lub p q is a pattern that matches all values matched by p and q. May raise Empty, when p and q are not compatible.

val lubs : Typedtree.pattern list -> Typedtree.pattern list -> Typedtree.pattern list

lubs [p1; ...; pn] [q1; ...; qk], where n < k, is [lub p1 q1; ...; lub pk qk].

val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list

Those two functions recombine one pattern and its arguments: For instance: (_,_)::p1::p2::rem -> (p1, p2)::rem The second one will replace mutable arguments by '_'

val set_args_erase_mutable : Typedtree.pattern -> Typedtree.pattern list -> Typedtree.pattern list

ppat_of_type builds an untyped or-pattern from its expected type. May raise Empty when type_expr is an empty variant

val pressure_variants : Env.t -> Typedtree.pattern list -> unit
val check_unused : (bool -> (string, Types.constructor_description) Hashtbl.t -> (string, Types.label_description) Hashtbl.t -> Parsetree.pattern -> Typedtree.pattern option) -> Typedtree.case list -> unit
val irrefutable : Typedtree.pattern -> bool
val inactive : partial:Typedtree.partial -> Typedtree.pattern -> bool

An inactive pattern is a pattern, matching against which can be duplicated, erased or delayed without change in observable behavior of the program. Patterns containing (lazy _) subpatterns or reads of mutable fields are active.

val check_ambiguous_bindings : Typedtree.case list -> unit
val some_private_tag : Asttypes.label
OCaml

Innovation. Community. Security.