package zanuda

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

zanuda-2.1.0.tbz
sha256=9f6f5684ff7329cf84086e6239f02060e711c369fac1553a55e1cd53d8aa8234
sha512=d90e36fc67ba2f1adc13a964a39c46ec354201ea1ff400c5dfe5ab384e07edcc8d2ec42dc053cdc091e217c4183d97a2d33ac12d3977b65defbac506a0b3418e

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
56
57
58
59
60
61
62
63
64
65
(** 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-2026, 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]
[%%if ocaml_version < (5, 4, 0)]

let get_cd_name cd = cd.Types.cstr_name

[%%endif]
[%%if ocaml_version >= (5, 5, 0)]

let get_cd_name cd = cd.Data_types.cstr_name

[%%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 (get_cd_name cd) "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