package merlin-lib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=60a630f59203a9ce7047a5f04d0f239945960dac6f38102922e328b6d2657384
sha512=19f8ec152356873e29c05b971a529146bb7079929037c2b35a5c0afb0b3adf662341ee8527282c5fdd16de391d01c2c469fc8629af9e0ae443fa9f42472b70bb
doc/merlin-lib.ocaml_typing/Ocaml_typing/Parmatch/index.html
Module Ocaml_typing.Parmatch
Source
Detection of partial matches and unused match cases.
const_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]
.
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
val complete_constrs :
Types.constructor_description Typedtree.pattern_data ->
Types.constructor_description list ->
Types.constructor_description list
ppat_of_type
builds an untyped pattern from its expected type, for explosion of wildcard patterns in Typecore.type_pat.
There are four interesting cases:
- the type is empty (
PT_empty
) - no further explosion is necessary (
PT_any
) - a single pattern is generated, from a record or tuple type or a single-variant type (
PE_single
) - an or-pattern is generated, in the case that all branches are GADT constructors (
PE_gadt_cases
).
type ppat_of_type =
| PT_empty
| PT_any
| PT_pattern of pat_explosion * Ocaml_parsing.Parsetree.pattern * (string, Types.constructor_description) Hashtbl.t * (string, Types.label_description) Hashtbl.t
val pressure_variants_in_computation_pattern :
Env.t ->
Typedtree.computation Typedtree.general_pattern list ->
unit
val check_partial :
((string, Types.constructor_description) Hashtbl.t ->
(string, Types.label_description) Hashtbl.t ->
Ocaml_parsing.Parsetree.pattern ->
Typedtree.pattern option) ->
Ocaml_parsing.Location.t ->
Typedtree.value Typedtree.case list ->
Typedtree.partial
check_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 ->
(string, Types.constructor_description) Hashtbl.t ->
(string, Types.label_description) Hashtbl.t ->
Ocaml_parsing.Parsetree.pattern ->
Typedtree.pattern option) ->
Typedtree.value Typedtree.case list ->
unit
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 complete_partial :
pred:
((Ocaml_parsing.Asttypes.label, Types.constructor_description) Hashtbl.t ->
(Ocaml_parsing.Asttypes.label, Types.label_description) Hashtbl.t ->
Ocaml_parsing.Parsetree.pattern ->
Typedtree.pattern option) ->
Typedtree.pattern list list ->
(Typedtree.pattern
* ((Ocaml_parsing.Asttypes.label, Types.constructor_description) Hashtbl.t
* (Ocaml_parsing.Asttypes.label, Types.label_description) Hashtbl.t)
option)
list
val return_unused :
Typedtree.pattern list ->
[ `Unused of Typedtree.pattern
| `Unused_subs of Typedtree.pattern * Typedtree.pattern list ]
list