Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | <!DOCTYPE html>\r |
2 | <html lang="en">\r | |
3 | <head>\r | |
4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r | |
5 | <meta name="generator" content="AsciiDoc 8.6.9">\r | |
6 | <title>MLBasisSyntaxAndSemantics</title>\r | |
7 | <link rel="stylesheet" href="./asciidoc.css" type="text/css">\r | |
8 | <link rel="stylesheet" href="./pygments.css" type="text/css">\r | |
9 | \r | |
10 | \r | |
11 | <script type="text/javascript" src="./asciidoc.js"></script>\r | |
12 | <script type="text/javascript">\r | |
13 | /*<![CDATA[*/\r | |
14 | asciidoc.install();\r | |
15 | /*]]>*/\r | |
16 | </script>\r | |
17 | <link rel="stylesheet" href="./mlton.css" type="text/css">\r | |
18 | </head>\r | |
19 | <body class="article">\r | |
20 | <div id="banner">\r | |
21 | <div id="banner-home">\r | |
22 | <a href="./Home">MLton 20180207</a>\r | |
23 | </div>\r | |
24 | </div>\r | |
25 | <div id="header">\r | |
26 | <h1>MLBasisSyntaxAndSemantics</h1>\r | |
27 | </div>\r | |
28 | <div id="content">\r | |
29 | <div id="preamble">\r | |
30 | <div class="sectionbody">\r | |
31 | <div class="paragraph"><p>An <a href="MLBasis">ML Basis</a> (MLB) file should have the <span class="monospaced">.mlb</span> suffix and\r | |
32 | should contain a basis declaration.</p></div>\r | |
33 | </div>\r | |
34 | </div>\r | |
35 | <div class="sect1">\r | |
36 | <h2 id="_syntax">Syntax</h2>\r | |
37 | <div class="sectionbody">\r | |
38 | <div class="paragraph"><p>A basis declaration (<em>basdec</em>) must be one of the following forms.</p></div>\r | |
39 | <div class="ulist"><ul>\r | |
40 | <li>\r | |
41 | <p>\r | |
42 | <span class="monospaced">basis</span> <em>basid</em> <span class="monospaced">=</span> <em>basexp</em> (<span class="monospaced">and</span> <em>basid</em> <span class="monospaced">=</span> <em>basexp</em>)<sup>*</sup>\r | |
43 | </p>\r | |
44 | </li>\r | |
45 | <li>\r | |
46 | <p>\r | |
47 | <span class="monospaced">open</span> <em>basid<sub>1</sub></em> … <em>basid<sub>n</sub></em>\r | |
48 | </p>\r | |
49 | </li>\r | |
50 | <li>\r | |
51 | <p>\r | |
52 | <span class="monospaced">local</span> <em>basdec</em> <span class="monospaced">in</span> <em>basdec</em> <span class="monospaced">end</span>\r | |
53 | </p>\r | |
54 | </li>\r | |
55 | <li>\r | |
56 | <p>\r | |
57 | <em>basdec</em> [<span class="monospaced">;</span>] <em>basdec</em>\r | |
58 | </p>\r | |
59 | </li>\r | |
60 | <li>\r | |
61 | <p>\r | |
62 | <span class="monospaced">structure</span> <em>strid</em> [<span class="monospaced">=</span> <em>strid</em>] (<span class="monospaced">and</span> <em>strid</em>[<span class="monospaced">=</span> <em>strid</em>])<sup>*</sup>\r | |
63 | </p>\r | |
64 | </li>\r | |
65 | <li>\r | |
66 | <p>\r | |
67 | <span class="monospaced">signature</span> <em>sigid</em> [<span class="monospaced">=</span> <em>sigid</em>] (<span class="monospaced">and</span> <em>sigid</em> [<span class="monospaced">=</span> <em>sigid</em>])<sup>*</sup>\r | |
68 | </p>\r | |
69 | </li>\r | |
70 | <li>\r | |
71 | <p>\r | |
72 | <span class="monospaced">functor</span> <em>funid</em> [<span class="monospaced">=</span> <em>funid</em>] (<span class="monospaced">and</span> <em>funid</em> [<span class="monospaced">=</span> <em>funid</em>])<sup>*</sup>\r | |
73 | </p>\r | |
74 | </li>\r | |
75 | <li>\r | |
76 | <p>\r | |
77 | <em>path</em><span class="monospaced">.sml</span>, <em>path</em><span class="monospaced">.sig</span>, or <em>path</em><span class="monospaced">.fun</span>\r | |
78 | </p>\r | |
79 | </li>\r | |
80 | <li>\r | |
81 | <p>\r | |
82 | <em>path</em><span class="monospaced">.mlb</span>\r | |
83 | </p>\r | |
84 | </li>\r | |
85 | <li>\r | |
86 | <p>\r | |
87 | <span class="monospaced">ann</span> <span class="monospaced">"</span><em>ann</em><span class="monospaced">"</span> <span class="monospaced">in</span> <em>basdec</em> <span class="monospaced">end</span>\r | |
88 | </p>\r | |
89 | </li>\r | |
90 | </ul></div>\r | |
91 | <div class="paragraph"><p>A basis expression (<em>basexp</em>) must be of one the following forms.</p></div>\r | |
92 | <div class="ulist"><ul>\r | |
93 | <li>\r | |
94 | <p>\r | |
95 | <span class="monospaced">bas</span> <em>basdec</em> <span class="monospaced">end</span>\r | |
96 | </p>\r | |
97 | </li>\r | |
98 | <li>\r | |
99 | <p>\r | |
100 | <em>basid</em>\r | |
101 | </p>\r | |
102 | </li>\r | |
103 | <li>\r | |
104 | <p>\r | |
105 | <span class="monospaced">let</span> <em>basdec</em> <span class="monospaced">in</span> <em>basexp</em> <span class="monospaced">end</span>\r | |
106 | </p>\r | |
107 | </li>\r | |
108 | </ul></div>\r | |
109 | <div class="paragraph"><p>Nested SML-style comments (enclosed with <span class="monospaced">(*</span> and <span class="monospaced">*)</span>) are ignored\r | |
110 | (but <a href="LineDirective">LineDirective</a>s are recognized).</p></div>\r | |
111 | <div class="paragraph"><p>Paths can be relative or absolute. Relative paths are relative to the\r | |
112 | directory containing the MLB file. Paths may include path variables\r | |
113 | and are expanded according to a <a href="MLBasisPathMap">path map</a>. Unquoted\r | |
114 | paths may include alpha-numeric characters and the symbols "<span class="monospaced">-</span>" and\r | |
115 | "<span class="monospaced">_</span>", along with the arc separator "<span class="monospaced">/</span>" and extension separator\r | |
116 | "<span class="monospaced">.</span>". More complicated paths, including paths with spaces, may be\r | |
117 | included by quoting the path with <span class="monospaced">"</span>. A quoted path is lexed as an\r | |
118 | SML string constant.</p></div>\r | |
119 | <div class="paragraph"><p><a href="MLBasisAnnotations">Annotations</a> allow a library author to\r | |
120 | control options that affect the elaboration of SML source files.</p></div>\r | |
121 | </div>\r | |
122 | </div>\r | |
123 | <div class="sect1">\r | |
124 | <h2 id="_semantics">Semantics</h2>\r | |
125 | <div class="sectionbody">\r | |
126 | <div class="paragraph"><p>There is a <a href="MLBasis.attachments/mlb-formal.pdf">formal semantics</a> for\r | |
127 | ML Basis files in the style of the\r | |
128 | <a href="DefinitionOfStandardML">Definition</a>. Here, we give an informal\r | |
129 | explanation.</p></div>\r | |
130 | <div class="paragraph"><p>An SML structure is a collection of types, values, and other\r | |
131 | structures. Similarly, a basis is a collection, but of more kinds of\r | |
132 | objects: types, values, structures, fixities, signatures, functors,\r | |
133 | and other bases.</p></div>\r | |
134 | <div class="paragraph"><p>A basis declaration denotes a basis. A structure, signature, or\r | |
135 | functor declaration denotes a basis containing the corresponding\r | |
136 | module. Sequencing of basis declarations merges bases, with later\r | |
137 | definitions taking precedence over earlier ones, just like sequencing\r | |
138 | of SML declarations. Local declarations provide name hiding, just\r | |
139 | like SML local declarations. A reference to an SML source file causes\r | |
140 | the file to be elaborated in the basis extant at the point of\r | |
141 | reference. A reference to an MLB file causes the basis denoted by\r | |
142 | that MLB file to be imported — the basis at the point of reference\r | |
143 | does <em>not</em> affect the imported basis.</p></div>\r | |
144 | <div class="paragraph"><p>Basis expressions and basis identifiers allow binding a basis to a\r | |
145 | name.</p></div>\r | |
146 | <div class="paragraph"><p>An MLB file is elaborated starting in an empty basis. Each MLB file\r | |
147 | is elaborated and evaluated only once, with the result being cached.\r | |
148 | Subsequent references use the cached value. Thus, any observable\r | |
149 | effects due to evaluation are not duplicated if the MLB file is\r | |
150 | referred to multiple times.</p></div>\r | |
151 | </div>\r | |
152 | </div>\r | |
153 | </div>\r | |
154 | <div id="footnotes"><hr></div>\r | |
155 | <div id="footer">\r | |
156 | <div id="footer-text">\r | |
157 | </div>\r | |
158 | <div id="footer-badges">\r | |
159 | </div>\r | |
160 | </div>\r | |
161 | </body>\r | |
162 | </html>\r |