package zanuda

  1. Overview
  2. Docs
Linter for OCaml+dune projects

Install

dune-project
 Dependency

Authors

Maintainers

Sources

zanuda-2.0.0.tbz
sha256=0108d8d6e6e23bfe5e5cdade27ae434db921ed4b6f522ea71800f14a7662230e
sha512=c8d633f4083867dfc73caf3b51b63c8c01771f5c286aa0a8357861044448e0b55df38eb695b997df470267ec921adae6f86c73d251fb3e965ac83ebb2c6b856c

doc/src/zanuda.tast_pattern/My_untype.ml.html

Source file My_untype.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(** These extra functions are an extension of {!Untypeast} module from compiler libs.
    Maybe in new versions of compiler they will be available out of box. *)

[@@@ocaml.text "/*"]

(** Copyright 2021-2025, Kakadu. *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

[@@@ocaml.text "/*"]

[@@@coverage off]

(* This are helper functions related to OCaml compiler. Doesn't make sense to seriously test them *)

include Untypeast

(** {2 New functions} *)

[%%if ocaml_version < (4, 11, 0)]

let untype_expression = default_mapper.expr default_mapper

[%%endif]

let default_mapper =
  { Untypeast.default_mapper with
    expr =
      (fun self e ->
        match e.exp_desc with
        | Typedtree.Texp_construct
            ( _
            , cd
            , [ _
              ; ({ exp_desc = Texp_constant (Asttypes.Const_string (_str_fmt, _, None)) }
                 as fmt_str_expr)
              ] )
          when String.equal cd.Types.cstr_name "Format" ->
          default_mapper.expr self fmt_str_expr
        | _ -> default_mapper.expr self e)
  }
;;

let expr = default_mapper.expr default_mapper

let untype_stru_item si =
  match
    untype_structure
      Typedtree.{ str_items = [ si ]; str_type = Obj.magic 1; str_final_env = si.str_env }
  with
  | [ si ] -> si
  | _ -> failwith "A bug"
;;

let value_binding = default_mapper.value_binding default_mapper