Module Stmt.Fixed

module Pattern : sig ... end
include Common.Fixed.S2 with module First = Expr.Fixed and module Pattern := Pattern
module First = Expr.Fixed
type ('a, 'b) t = {
  1. pattern : ('a First.t, ('a, 'b) t) Pattern.t;
  2. meta : 'b;
}
val map : ('a -> 'c) -> ('b -> 'd) -> ('a, 'b) t -> ('c, 'd) t
val fold : ('c -> 'a -> 'c) -> ('c -> 'b -> 'c) -> 'c -> ('a, 'b) t -> 'c
include Ppx_compare_lib.Comparable.S2 with type ('a, 'b) t := ('a, 'b) t
val compare : 'a Base__Ppx_compare_lib.compare -> 'b Base__Ppx_compare_lib.compare -> ('a, 'b) t Base__Ppx_compare_lib.compare
include Ppx_hash_lib.Hashable.S2 with type ('a, 'b) t := ('a, 'b) t
val hash_fold_t : 'a Base__Ppx_hash_lib.hash_fold -> 'b Base__Ppx_hash_lib.hash_fold -> ('a, 'b) t Base__Ppx_hash_lib.hash_fold
include Sexplib0.Sexpable.S2 with type ('a, 'b) t := ('a, 'b) t
val t_of_sexp : (Sexplib0__.Sexp.t -> 'a) -> (Sexplib0__.Sexp.t -> 'b) -> Sexplib0__.Sexp.t -> ('a, 'b) t
val sexp_of_t : ('a -> Sexplib0__.Sexp.t) -> ('b -> Sexplib0__.Sexp.t) -> ('a, 'b) t -> Sexplib0__.Sexp.t
include Common.Foldable.S2 with type ('a, 'b) t := ('a, 'b) t
val fold_left : f:('c -> 'a -> 'c) -> g:('c -> 'b -> 'c) -> init:'c -> ('a, 'b) t -> 'c
val fold_right : f:('a -> 'c -> 'c) -> g:('b -> 'c -> 'c) -> init:'c -> ('a, 'b) t -> 'c
val any : pred_first:('a -> bool) -> pred_second:('b -> bool) -> ?init:bool -> ('a, 'b) t -> bool
val all : pred_first:('a -> bool) -> pred_second:('b -> bool) -> ?init:bool -> ('a, 'b) t -> bool
include Common.Pretty.S2 with type ('a, 'b) t := ('a, 'b) t
val pp : (Stdlib.Format.formatter -> 'a -> unit) -> (Stdlib.Format.formatter -> 'b -> unit) -> Stdlib.Format.formatter -> ('a, 'b) t -> unit
val fold_pattern : f:(('a * 'r1 First.Pattern.t) -> 'r1) -> g:(('b * ('r1, 'r2) Pattern.t) -> 'r2) -> ('a, 'b) t -> 'r2

fold_pattern traverses the data structure from the bottom up replacing the original meta data of First with type 'a with some result type 'r1 and the meta data at this level withtype 'b to another result type 'r2 and combines the result values on the way back up.

val rewrite_bottom_up : f:('a First.t -> 'a First.t) -> g:(('a, 'b) t -> ('a, 'b) t) -> ('a, 'b) t -> ('a, 'b) t

rewrite_bottom_up specializes fold_pattern so that the result type 'r1 is equal to the type of the nested fixed-point type i.e. 'r1 = 'a First.t and the result type 'r2 is equal to the top-level fixed-point type i.e. 'r2 = ('a,'b) t.

This also means that the function f can be written with our nested fixed-point type 'a First.t as its argument and g can be written with ('a,'b) t as its argument.

val unfold_pattern : f:('r1 -> 'a * 'r1 First.Pattern.t) -> g:('r2 -> 'b * ('r1, 'r2) Pattern.t) -> 'r2 -> ('a, 'b) t

unfold_pattern takes a seed value of type 'r2 and uses the function g to generate a tuple of meta-data and a pattern with types 'r1 and 'r2. The functions proceeds by recursively applying g to the contained values of type 'r2 and f to values of type 'r1 finishing when the pattern contains no values of type 'r1 or 'r2.

val rewrite_top_down : f:('a First.t -> 'a First.t) -> g:(('a, 'b) t -> ('a, 'b) t) -> ('a, 'b) t -> ('a, 'b) t

rewrite_top_down specializes unfold_pattern in a manner analogous to how rewrite_bottom_up specializes fold_pattern