Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 91 lines (68 sloc) 2.456 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (* Guidelines for module implementation *)
20 (*
21 - You MUST provide the interface of your implementation in a mli
22 except if your implementation provides essentially type definitions :
23 in this case your module should be named myModuleInterface.ml.
24
25 - You must put the license at the beginning of the code
26
27 - Don't use ocamldoc comments in the implementation of your module,
28 use simple comments.
29 *)
30
31 (* Dependencies *)
32 (* module Bar = Foo.Bar
33 ...
34 *)
35
36 (* Shorthands *)
37 (* module B = Baz
38 ...
39 *)
40
41 (* Type aliases *)
42 (*
43 In this part of the module, you can define type aliases, for a better readability.
44 *)
45
46 type filename = string
47 type line_number = int
48
49
50 (* Error report *)
51 (*
52 In case of an error you would like to report but should not be caught by
53 anyone, use errors from OManager module
54 In case of an error you would like to put in an exception which can be
55 caught later, act this way :
56 - Define a type error
57 - Define an exception with argument of type error
58 - Define a printer to print your error
59
60 If the error cases are very simple, you may use type string for error,
61 if not, the guideline is to use a sum type.
62 *)
63
64 type error = string
65 exception Exception of error
66 let pp_error fmt err = Format.fprintf fmt "Error : %s" err
67
68 (* Shorthands for warnings *)
69 (*
70 You can define operators to raise warning. Like (!!) (??) (!?) (?!) ...
71 which will call OManager.warning, with a coherent and documented warning class.
72 *)
73
74 (* Debug *)
75 (* Define here ppdebug messages *)
76
77 let debug fmt =
78 OManager.printf ("@{<cyan>[MyModule]@}@ @[<2>"^^fmt^^"@]@.")
79
80 let _ =
81 #<If:CHECK_VARS $minlevel 1>
82 debug "print some debug of level %d@\n" 1
83 #<End>
84
85
86 (* Comment documenting function 1 *)
87 let function1 () = ()
88
89 (* Comment documenting function 2 *)
90 let function2 () = ()
Something went wrong with that request. Please try again.