File: module_indent.ml

package info (click to toggle)
ocamlformat 0.28.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,436 kB
  • sloc: ml: 63,321; pascal: 4,769; lisp: 229; sh: 217; makefile: 121
file content (66 lines) | stat: -rw-r--r-- 1,769 bytes parent folder | download | duplicates (2)
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
66
(* Signature module type with attributes and comments *)
module type M = sig
    type t
    [@@ocaml.doc
      "Abstract type....................................................."]
    (** Type of elements *)

    val f : (string * int) list -> int
    [@@ocaml.doc "Processes a list of (string * int) pairs"]
    (** Function operating on a list of (string * int) *)

    (** Inner module type *)
    module type Inner = sig
        type inner
        [@@ocaml.doc
          "Inner abstract \
           type.................................................."]

        val f : int -> int
        [@@deprecated "Use the outer module’s `f` instead"]
        [@@ocaml.doc "Deprecated inner function"]
    end
end

(* Module implementing part of M *)
module A : sig
    type t

    val f : (string * int) list -> int
    [@@ocaml.doc "Dummy implementation of M.f"]
end = struct
    type t

    (* Function with extra params  *)
    let f s l =
      (* ignore params and return dummy result *)
      0
end

(* Core module hierarchy with attributes *)
module Core = struct
    module Int = struct
        module T = struct
            type t = int
            [@@ocaml.doc
              "Int alias with core extensions..........................."]

            let compare = compare [@inline always]

            let ( + ) x y = x + y
            [@@ocaml.doc "Addition for core ints..........................."]
        end

        include T

        (* Map functor application with inline doc *)
        module Map = Map.Make (T)
        [@@ocaml.doc "Map over core ints......................"]
    end

    (* Re-export with comment *)
    module Std = struct
        module Int = Int
        [@@ocaml.doc "Standard Int re-export......................"]
    end
end