package codept-lib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file schema.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
open Schematic

module Lbl = struct
  module M2l = Label(struct let l = "m2l" end)
  module Deps = Label(struct let l = "deps" end)
  module Namespace = Label(struct let l = "namespace" end)
  type m2l = M2l.t
  type deps = Deps.t
  type namespace = Namespace.t
end

let version = { Version.major = 0; minor=11; patch=0 }


let m2l = { Schematic.Ext.title = "codept/m2l/0.11.0";
            description = "module level ocaml file skeleton";
            version;
            label = Lbl.M2l.l;
            inner = M2l.sch
          }

let namespace = { Schematic.Ext.title = "codept/namespace/0.11.0";
             description = "namespaced compilation units";
             version;
             label = Lbl.Namespace.l;
             inner = Module.Namespace.sch
           }



module Module = Label(struct let l = "module" end)
module Ml = Label(struct let l = "ml" end)
module Mli = Label(struct let l = "mli" end)

let path: _ s = Namespaced.sch
type p = Namespaced.t

type local_association =
  { path: p; ml: string option; mli: string option }

let raw_assoc =
  Obj [
    Req, Module.l, path <?> "Toplevel module";
    Opt, Ml.l, String <?> "Implementation (.ml) file";
    Opt, Mli.l, String <?> "Interface (.mli) file"
  ]
  <?> "This type keeps track of which implementation file (.ml) \
       and interface file (.mli) provided a toplevel module"

let local_association =
  custom raw_assoc
    (fun r -> [Module.l $= r.path
              ; Ml.l $=? r.ml
              ; Mli.l $=? r.mli])
    Record.(fun [_,path; _,ml; _, mli ] ->
        { path; ml; mli } )

type library_module = { path:p; lib:p}
module Lib = Label(struct let l = "lib" end)

module R = Schematic.Record
let lib =
  custom
    (Obj [Req, Module.l, path; Req, Lib.l, path] <?>
     "Library dependency: module path followed by the library path")
    (fun (r: library_module) -> [Module.l $= r.path; Lib.l $= r.lib])
    (let open R in fun [_,path;_,lib] -> {path;lib})


module Local = Label(struct let l = "local" end)
module Unknown = Label(struct let l ="unknown" end)
module Deps = Label(struct let l = "deps" end)


module File = Label(struct let l = "file" end)

type unit = { file: string; deps: p list }

let raw_unit =
  Obj [
    Req, File.l, String <?> "File name";
    Opt, Deps.l, Array path <?> "list of dependencies"
  ]

let unit =
  let e: _ list = [] in
  let ($=$) x l = if l = L.[] then x $=? None else x $=? Some l in
  custom  raw_unit
    (fun d -> [ File.l $= d.file; Deps.l $=$ d.deps ])
    (let open R in fun [_, file; _,deps] -> {file; deps = Option.default e deps } )



module Dependencies = Label(struct let l = "dependencies" end)
module Atlas = Label(struct let l = "atlas" end)

type deps = {
  dependencies: unit list;
  local: local_association list;
  library: library_module list;
  unknown: p list;
}

let deps = Obj [
    Req, Dependencies.l, Array unit <?> "Infered dependencies" ;
    Opt, Local.l, Array local_association <?> "Modules provided by local files";
    Opt, Lib.l, Array lib <?> "Modules provided by libraries";
    Opt, Unknown.l, Array path <?> "Unknown modules";
  ]

let deps =
  let list x = Option.default ([]: _ list) x in
  let ($=$) x l = if l = L.[] then x $=? None else x $=? Some l in
  let open Record in
  custom  deps
    (fun {dependencies; local; library; unknown }->
       [ Dependencies.l $= dependencies;
         Local.l $=$ local;
         Lib.l $=$ library;
         Unknown.l $=$ unknown
       ] )
    (fun [_,dependencies;_,local;_,lib;_,u] ->
       {dependencies;
        local=list local;
        library=list lib;
        unknown=list u
       } )


let x  = {
  Ext.title ="codept.0.11.0/deps";
  description = "dependencies and module-to-files mapping of ocaml project";
  label = Lbl.Deps.l;
  version;
  inner = deps;
}

let schema = x