package merlin-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b0dcad092aaaf7a23f65ab9a089e8761bd665cc72357909e0ac6c2182f4fc2d4
sha512=9987baf2b2e82bab4c90a328bfcba9945e797e0f3d947156f04435ee84b49542844b379e35a79027c3ffe81f4b7a8f1c60803233999b4c039d4598033371880d
doc/merlin-lib.ocaml_typing/Ocaml_typing/Parmatch/index.html
Module Ocaml_typing.ParmatchSource
Detection of partial matches and unused match cases.
type 'pattern parmatch_case = {pattern : 'pattern;has_guard : bool;needs_refute : bool;(*true if the program text claims the case is unreachable, a la
*)function _ -> .
}Most checks in this file need not access all information about a case, and just need a few pieces of information. parmatch_case is those few pieces of information.
type 'category typed_case := 'category Typedtree.general_pattern parmatch_caseval untyped_case :
Ocaml_parsing.Parsetree.case ->
Ocaml_parsing.Parsetree.pattern parmatch_caseconst_compare c1 c2 compares the actual values represented by c1 and c2, while simply using Stdlib.compare would compare the representations.
cf. MPR#5758
le_pat p q means: forall V, V matches q implies V matches p
le_pats (p1 .. pm) (q1 .. qn) means: forall i <= m, le_pat pi qi
Exported compatibility functor, abstracted over constructor equality
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.
lubs [p1; ...; pn] [q1; ...; qk], where n < k, is [lub p1 q1; ...; lub pk qk].
This function recombines one pattern and its arguments: For instance: (_,_)::p1::p2::rem -> (p1, p2)::rem
val complete_constrs :
Types.constructor_description Typedtree.pattern_data ->
Types.constructor_description list ->
Types.constructor_description listpats_of_type builds a list of patterns from a given expected type, for explosion of wildcard patterns in Typecore.type_pat.
There are four interesting cases:
- the type is empty ()
- no further explosion is necessary (
Pat_any) - a single pattern is generated, from a record or tuple type or a single-variant type (
tp) - a list of patterns, in the case that all branches are GADT constructors (
tp1; ..; tpn).
val pressure_variants_in_computation_pattern :
Env.t ->
Typedtree.computation Typedtree.general_pattern list ->
unitval check_partial :
(Typedtree.pattern -> Typedtree.pattern option) ->
Ocaml_parsing.Location.t ->
Typedtree.value typed_case list ->
Typedtree.partialcheck_partial pred loc caselist and check_unused refute pred caselist are called with a function pred which will be given counter-example candidates: they may be partially ill-typed, and have to be type-checked to extract a valid counter-example. pred returns a valid counter-example or None. refute indicates that check_unused was called on a refutation clause.
val check_unused :
(bool -> Typedtree.pattern -> Typedtree.pattern option) ->
Typedtree.value typed_case list ->
unitAn 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 complete_partial :
pred:(Typedtree.pattern -> Typedtree.pattern option) ->
Typedtree.pattern list list ->
Typedtree.pattern listval return_unused :
Typedtree.pattern list ->
[ `Unused of Typedtree.pattern
| `Unused_subs of Typedtree.pattern * Typedtree.pattern list ]
list