Debian Codegraph @

doc/guide/src/MLBasisAnnotations.adoc

raw
1 = MLBasisAnnotations
2
3 <<MLBasis#,ML Basis>> annotations control options that affect the
4 elaboration of SML source files. Conceptually, a basis file is
5 elaborated in a default annotation environment (just as it is
6 elaborated in an empty basis). The declaration
7
8 ****
9 `ann` `"_ann_"` `in` `_basdec_` `end`
10 ****
11
12 merges the annotation `_ann_` with the "current" annotation
13 environment for the elaboration of `_basdec_`. To allow for future
14 expansion, `"_ann_"` is lexed as a single SML string constant. To
15 conveniently specify multiple annotations, the following derived form
16 is provided:
17
18 ****
19 `ann` `"_ann_` ( `_ann_"` )^{plus}^ `in` `_basdec_` `end`
20 =>
21 `ann` `"_ann_"` `in` `ann` ( `"_ann_"` )^{plus}^ `in` `_basdec_` `end` `end`
22 ****
23
24 Here are the available annotations. In the explanation below, for
25 annotations that take an argument, the first value listed is the
26 default.
27
28 * `allowFFI {false|true}`
29 +
30 If `true`, allow `_address`, `_export`, `_import`, and `_symbol`
31 expressions to appear in source files. See
32 <<ForeignFunctionInterface#>>.
33
34 * `allowSuccessorML {false|true}`
35 +
36 Allow or disallow all of the <<SuccessorML#>> features. This is a
37 proxy for all of the following annotations.
38
39 ** `allowDoDecls {false|true}`
40 +
41 If `true`, allow a `do _exp_` declaration form.
42
43 ** `allowExtendedConsts {false|true}`
44 +
45 Allow or disallow all of the extended constants features. This is a
46 proxy for all of the following annotations.
47
48 *** `allowExtendedNumConsts {false|true}`
49 +
50 If `true`, allow extended numeric constants.
51
52 *** `allowExtendedTextConsts {false|true}`
53 +
54 If `true`, allow extended text constants.
55
56 ** `allowLineComments {false|true}`
57 +
58 If `true`, allow line comments beginning with the token ``(*)``.
59
60 ** `allowOptBar {false|true}`
61 +
62 If `true`, allow a bar to appear before the first match rule of a
63 `case`, `fn`, or `handle` expression, allow a bar to appear before the
64 first function-value binding of a `fun` declaration, and allow a bar
65 to appear before the first constructor binding or description of a
66 `datatype` declaration or specification.
67
68 ** `allowOptSemicolon {false|true}`
69 +
70 If `true`, allows a semicolon to appear after the last expression in a
71 sequence expression or `let` body.
72
73 ** `allowOrPats {false|true}`
74 +
75 If `true`, allows disjunctive (a.k.a., "or") patterns of the form
76 `_pat_ | _pat_`.
77
78 ** `allowRecordPunExps {false|true}`
79 +
80 If `true`, allows record punning expressions.
81
82 ** `allowSigWithtype {false|true}`
83 +
84 If `true`, allows `withtype` to modify a `datatype` specification in a
85 signature.
86
87 ** `allowVectorExpsAndPats {false|true}`
88 +
89 Allow or disallow vector expressions and vector patterns. This is a
90 proxy for all of the following annotations.
91
92 *** `allowVectorExps {false|true}`
93 +
94 If `true`, allow vector expressions.
95
96 *** `allowVectorPats {false|true}`
97 +
98 If `true`, allow vector patterns.
99
100 * `forceUsed`
101 +
102 Force all identifiers in the basis denoted by the body of the `ann` to
103 be considered used; use in conjunction with `warnUnused true`.
104
105 * `nonexhaustiveBind {warn|error|ignore}`
106 +
107 If `error` or `warn`, report nonexhaustive patterns in `val`
108 declarations (i.e., pattern-match failures that raise the `Bind`
109 exception). An error will abort a compile, while a warning will not.
110
111 * `nonexhaustiveExnBind {default|ignore}`
112 +
113 If `ignore`, suppress errors and warnings about nonexhaustive matches
114 in `val` declarations that arise solely from unmatched exceptions.
115 If `default`, follow the behavior of `nonexhaustiveBind`.
116
117 * `nonexhaustiveExnMatch {default|ignore}`
118 +
119 If `ignore`, suppress errors and warnings about nonexhaustive matches
120 in `fn` expressions, `case` expressions, and `fun` declarations that
121 arise solely from unmatched exceptions. If `default`, follow the
122 behavior of `nonexhaustiveMatch`.
123
124 * `nonexhaustiveExnRaise {ignore|default}`
125 +
126 If `ignore`, suppress errors and warnings about nonexhaustive matches
127 in `handle` expressions that arise solely from unmatched exceptions.
128 If `default`, follow the behavior of `nonexhaustiveRaise`.
129
130 * `nonexhaustiveMatch {warn|error|ignore}`
131 +
132 If `error` or `warn`, report nonexhaustive patterns in `fn`
133 expressions, `case` expressions, and `fun` declarations (i.e.,
134 pattern-match failures that raise the `Match` exception). An error
135 will abort a compile, while a warning will not.
136
137 * `nonexhaustiveRaise {ignore|warn|error}`
138 +
139 If `error` or `warn`, report nonexhaustive patterns in `handle`
140 expressions (i.e., pattern-match failures that implicitly (re)raise
141 the unmatched exception). An error will abort a compile, while a
142 warning will not.
143
144 * `redundantBind {warn|error|ignore}`
145 +
146 If `error` or `warn`, report redundant patterns in `val` declarations.
147 An error will abort a compile, while a warning will not.
148
149 * `redundantMatch {warn|error|ignore}`
150 +
151 If `error` or `warn`, report redundant patterns in `fn` expressions,
152 `case` expressions, and `fun` declarations. An error will abort a
153 compile, while a warning will not.
154
155 * `redundantRaise {warn|error|ignore}`
156 +
157 If `error` or `warn`, report redundant patterns in `handle`
158 expressions. An error will abort a compile, while a warning will not.
159
160 * `resolveScope {strdec|dec|topdec|program}`
161 +
162 Used to control the scope at which overload constraints are resolved
163 to default types (if not otherwise resolved by type inference) and the
164 scope at which unresolved flexible record constraints are reported.
165 +
166 The syntactic-class argument means to perform resolution checks at the
167 smallest enclosing syntactic form of the given class. The default
168 behavior is to resolve at the smallest enclosing _strdec_ (which is
169 equivalent to the largest enclosing _dec_). Other useful behaviors
170 are to resolve at the smallest enclosing _topdec_ (which is equivalent
171 to the largest enclosing _strdec_) and at the smallest enclosing
172 _program_ (which corresponds to a single `.sml` file and does not
173 correspond to the whole `.mlb` program).
174
175 * `sequenceNonUnit {ignore|error|warn}`
176 +
177 If `error` or `warn`, report when `e1` is not of type `unit` in the
178 sequence expression `(e1; e2)`. This can be helpful in detecting
179 curried applications that are mistakenly not fully applied. To
180 silence spurious messages, you can use `ignore e1`.
181
182 * `valrecConstr {warn|error|ignore}`
183 +
184 If `error` or `warn`, report when a `val rec` (or `fun`) declaration
185 redefines an identifier that previously had constructor status. An
186 error will abort a compile, while a warning will not.
187
188 * `warnUnused {false|true}`
189 +
190 Report unused identifiers.
191
192 == Next Steps
193
194 * <<MLBasisAnnotationExamples#>>
195 * <<WarnUnusedAnomalies#>>