28447
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{Adaption}%
|
|
4 |
%
|
|
5 |
\isadelimtheory
|
|
6 |
%
|
|
7 |
\endisadelimtheory
|
|
8 |
%
|
|
9 |
\isatagtheory
|
|
10 |
\isacommand{theory}\isamarkupfalse%
|
|
11 |
\ Adaption\isanewline
|
|
12 |
\isakeyword{imports}\ Setup\isanewline
|
|
13 |
\isakeyword{begin}%
|
|
14 |
\endisatagtheory
|
|
15 |
{\isafoldtheory}%
|
|
16 |
%
|
|
17 |
\isadelimtheory
|
|
18 |
%
|
|
19 |
\endisadelimtheory
|
|
20 |
%
|
|
21 |
\isamarkupsection{Adaption to target languages \label{sec:adaption}%
|
|
22 |
}
|
|
23 |
\isamarkuptrue%
|
|
24 |
%
|
|
25 |
\isamarkupsubsection{Common adaption cases%
|
|
26 |
}
|
|
27 |
\isamarkuptrue%
|
|
28 |
%
|
|
29 |
\begin{isamarkuptext}%
|
|
30 |
The \hyperlink{theory.HOL}{\mbox{\isa{HOL}}} \hyperlink{theory.Main}{\mbox{\isa{Main}}} theory already provides a code
|
|
31 |
generator setup
|
|
32 |
which should be suitable for most applications. Common extensions
|
|
33 |
and modifications are available by certain theories of the \isa{HOL}
|
|
34 |
library; beside being useful in applications, they may serve
|
|
35 |
as a tutorial for customising the code generator setup (see below
|
|
36 |
\secref{sec:adaption_mechanisms}).
|
|
37 |
|
|
38 |
\begin{description}
|
|
39 |
|
|
40 |
\item[\hyperlink{theory.Code-Integer}{\mbox{\isa{Code{\isacharunderscore}Integer}}}] represents \isa{HOL} integers by big
|
|
41 |
integer literals in target languages.
|
|
42 |
\item[\hyperlink{theory.Code-Char}{\mbox{\isa{Code{\isacharunderscore}Char}}}] represents \isa{HOL} characters by
|
|
43 |
character literals in target languages.
|
|
44 |
\item[\hyperlink{theory.Code-Char-chr}{\mbox{\isa{Code{\isacharunderscore}Char{\isacharunderscore}chr}}}] like \isa{Code{\isacharunderscore}Char},
|
|
45 |
but also offers treatment of character codes; includes
|
|
46 |
\hyperlink{theory.Code-Char-chr}{\mbox{\isa{Code{\isacharunderscore}Char{\isacharunderscore}chr}}}.
|
|
47 |
\item[\hyperlink{theory.Efficient-Nat}{\mbox{\isa{Efficient{\isacharunderscore}Nat}}}] \label{eff_nat} implements natural numbers by integers,
|
|
48 |
which in general will result in higher efficiency; pattern
|
|
49 |
matching with \isa{{\isadigit{0}}} / \isa{Suc}
|
|
50 |
is eliminated; includes \hyperlink{theory.Code-Integer}{\mbox{\isa{Code{\isacharunderscore}Integer}}}.
|
|
51 |
\item[\hyperlink{theory.Code-Index}{\mbox{\isa{Code{\isacharunderscore}Index}}}] provides an additional datatype
|
|
52 |
\isa{index} which is mapped to target-language built-in integers.
|
|
53 |
Useful for code setups which involve e.g. indexing of
|
|
54 |
target-language arrays.
|
|
55 |
\item[\hyperlink{theory.Code-Message}{\mbox{\isa{Code{\isacharunderscore}Message}}}] provides an additional datatype
|
|
56 |
\isa{message{\isacharunderscore}string} which is isomorphic to strings;
|
|
57 |
\isa{message{\isacharunderscore}string}s are mapped to target-language strings.
|
|
58 |
Useful for code setups which involve e.g. printing (error) messages.
|
|
59 |
|
|
60 |
\end{description}
|
|
61 |
|
|
62 |
\begin{warn}
|
|
63 |
When importing any of these theories, they should form the last
|
|
64 |
items in an import list. Since these theories adapt the
|
|
65 |
code generator setup in a non-conservative fashion,
|
|
66 |
strange effects may occur otherwise.
|
|
67 |
\end{warn}%
|
|
68 |
\end{isamarkuptext}%
|
|
69 |
\isamarkuptrue%
|
|
70 |
%
|
|
71 |
\isamarkupsubsection{Adaption mechanisms \label{sec:adaption_mechanisms}%
|
|
72 |
}
|
|
73 |
\isamarkuptrue%
|
|
74 |
%
|
|
75 |
\begin{isamarkuptext}%
|
|
76 |
\begin{warn}
|
|
77 |
The mechanisms shown here are especially for the curious; the user
|
|
78 |
rarely needs to do anything on his own beyond the defaults in \isa{HOL}.
|
|
79 |
Adaption is a delicated task which requires a lot of dilligence since
|
|
80 |
it happend \emph{completely} outside the logic.
|
|
81 |
\end{warn}%
|
|
82 |
\end{isamarkuptext}%
|
|
83 |
\isamarkuptrue%
|
|
84 |
%
|
|
85 |
\begin{isamarkuptext}%
|
|
86 |
Consider the following function and its corresponding
|
|
87 |
SML code:%
|
|
88 |
\end{isamarkuptext}%
|
|
89 |
\isamarkuptrue%
|
|
90 |
%
|
|
91 |
\isadelimquoteme
|
|
92 |
%
|
|
93 |
\endisadelimquoteme
|
|
94 |
%
|
|
95 |
\isatagquoteme
|
|
96 |
\isacommand{primrec}\isamarkupfalse%
|
|
97 |
\ in{\isacharunderscore}interval\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}nat\ {\isasymtimes}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\ \isakeyword{where}\isanewline
|
|
98 |
\ \ {\isachardoublequoteopen}in{\isacharunderscore}interval\ {\isacharparenleft}k{\isacharcomma}\ l{\isacharparenright}\ n\ {\isasymlongleftrightarrow}\ k\ {\isasymle}\ n\ {\isasymand}\ n\ {\isasymle}\ l{\isachardoublequoteclose}%
|
|
99 |
\endisatagquoteme
|
|
100 |
{\isafoldquoteme}%
|
|
101 |
%
|
|
102 |
\isadelimquoteme
|
|
103 |
%
|
|
104 |
\endisadelimquoteme
|
|
105 |
%
|
|
106 |
\isadeliminvisible
|
|
107 |
%
|
|
108 |
\endisadeliminvisible
|
|
109 |
%
|
|
110 |
\isataginvisible
|
|
111 |
%
|
|
112 |
\endisataginvisible
|
|
113 |
{\isafoldinvisible}%
|
|
114 |
%
|
|
115 |
\isadeliminvisible
|
|
116 |
%
|
|
117 |
\endisadeliminvisible
|
|
118 |
%
|
|
119 |
\isadelimquoteme
|
|
120 |
%
|
|
121 |
\endisadelimquoteme
|
|
122 |
%
|
|
123 |
\isatagquoteme
|
|
124 |
%
|
|
125 |
\begin{isamarkuptext}%
|
|
126 |
\isaverbatim%
|
|
127 |
\noindent%
|
|
128 |
\verb|structure Example = |\newline%
|
|
129 |
\verb|struct|\newline%
|
|
130 |
\newline%
|
|
131 |
\verb|datatype nat = Suc of nat |\verb,|,\verb| Zero_nat;|\newline%
|
|
132 |
\newline%
|
|
133 |
\verb|datatype boola = False |\verb,|,\verb| True;|\newline%
|
|
134 |
\newline%
|
|
135 |
\verb|fun anda x True = x|\newline%
|
|
136 |
\verb| |\verb,|,\verb| anda x False = False|\newline%
|
|
137 |
\verb| |\verb,|,\verb| anda True x = x|\newline%
|
|
138 |
\verb| |\verb,|,\verb| anda False x = False;|\newline%
|
|
139 |
\newline%
|
|
140 |
\verb|fun less_nat m (Suc n) = less_eq_nat m n|\newline%
|
|
141 |
\verb| |\verb,|,\verb| less_nat n Zero_nat = False|\newline%
|
|
142 |
\verb|and less_eq_nat (Suc m) n = less_nat m n|\newline%
|
|
143 |
\verb| |\verb,|,\verb| less_eq_nat Zero_nat n = True;|\newline%
|
|
144 |
\newline%
|
|
145 |
\verb|fun in_interval (k, l) n = anda (less_eq_nat k n) (less_eq_nat n l);|\newline%
|
|
146 |
\newline%
|
|
147 |
\verb|end; (*struct Example*)|%
|
|
148 |
\end{isamarkuptext}%
|
|
149 |
\isamarkuptrue%
|
|
150 |
%
|
|
151 |
\endisatagquoteme
|
|
152 |
{\isafoldquoteme}%
|
|
153 |
%
|
|
154 |
\isadelimquoteme
|
|
155 |
%
|
|
156 |
\endisadelimquoteme
|
|
157 |
%
|
|
158 |
\begin{isamarkuptext}%
|
|
159 |
\noindent Though this is correct code, it is a little bit unsatisfactory:
|
|
160 |
boolean values and operators are materialised as distinguished
|
|
161 |
entities with have nothing to do with the SML-built-in notion
|
|
162 |
of \qt{bool}. This results in less readable code;
|
|
163 |
additionally, eager evaluation may cause programs to
|
|
164 |
loop or break which would perfectly terminate when
|
|
165 |
the existing SML \verb|bool| would be used. To map
|
|
166 |
the HOL \isa{bool} on SML \verb|bool|, we may use
|
|
167 |
\qn{custom serialisations}:%
|
|
168 |
\end{isamarkuptext}%
|
|
169 |
\isamarkuptrue%
|
|
170 |
%
|
|
171 |
\isadelimtt
|
|
172 |
%
|
|
173 |
\endisadelimtt
|
|
174 |
%
|
|
175 |
\isatagtt
|
|
176 |
\isacommand{code{\isacharunderscore}type}\isamarkupfalse%
|
|
177 |
\ bool\isanewline
|
|
178 |
\ \ {\isacharparenleft}SML\ {\isachardoublequoteopen}bool{\isachardoublequoteclose}{\isacharparenright}\isanewline
|
|
179 |
\isacommand{code{\isacharunderscore}const}\isamarkupfalse%
|
|
180 |
\ True\ \isakeyword{and}\ False\ \isakeyword{and}\ {\isachardoublequoteopen}op\ {\isasymand}{\isachardoublequoteclose}\isanewline
|
|
181 |
\ \ {\isacharparenleft}SML\ {\isachardoublequoteopen}true{\isachardoublequoteclose}\ \isakeyword{and}\ {\isachardoublequoteopen}false{\isachardoublequoteclose}\ \isakeyword{and}\ {\isachardoublequoteopen}{\isacharunderscore}\ andalso\ {\isacharunderscore}{\isachardoublequoteclose}{\isacharparenright}%
|
|
182 |
\endisatagtt
|
|
183 |
{\isafoldtt}%
|
|
184 |
%
|
|
185 |
\isadelimtt
|
|
186 |
%
|
|
187 |
\endisadelimtt
|
|
188 |
%
|
|
189 |
\begin{isamarkuptext}%
|
|
190 |
\noindent The \hyperlink{command.code-type}{\mbox{\isa{\isacommand{code{\isacharunderscore}type}}}} command takes a type constructor
|
|
191 |
as arguments together with a list of custom serialisations.
|
|
192 |
Each custom serialisation starts with a target language
|
|
193 |
identifier followed by an expression, which during
|
|
194 |
code serialisation is inserted whenever the type constructor
|
|
195 |
would occur. For constants, \hyperlink{command.code-const}{\mbox{\isa{\isacommand{code{\isacharunderscore}const}}}} implements
|
|
196 |
the corresponding mechanism. Each ``\verb|_|'' in
|
|
197 |
a serialisation expression is treated as a placeholder
|
|
198 |
for the type constructor's (the constant's) arguments.%
|
|
199 |
\end{isamarkuptext}%
|
|
200 |
\isamarkuptrue%
|
|
201 |
%
|
|
202 |
\isadelimquoteme
|
|
203 |
%
|
|
204 |
\endisadelimquoteme
|
|
205 |
%
|
|
206 |
\isatagquoteme
|
|
207 |
%
|
|
208 |
\begin{isamarkuptext}%
|
|
209 |
\isaverbatim%
|
|
210 |
\noindent%
|
|
211 |
\verb|structure Example = |\newline%
|
|
212 |
\verb|struct|\newline%
|
|
213 |
\newline%
|
|
214 |
\verb|datatype nat = Suc of nat |\verb,|,\verb| Zero_nat;|\newline%
|
|
215 |
\newline%
|
|
216 |
\verb|fun less_nat m (Suc n) = less_eq_nat m n|\newline%
|
|
217 |
\verb| |\verb,|,\verb| less_nat n Zero_nat = false|\newline%
|
|
218 |
\verb|and less_eq_nat (Suc m) n = less_nat m n|\newline%
|
|
219 |
\verb| |\verb,|,\verb| less_eq_nat Zero_nat n = true;|\newline%
|
|
220 |
\newline%
|
|
221 |
\verb|fun in_interval (k, l) n = (less_eq_nat k n) andalso (less_eq_nat n l);|\newline%
|
|
222 |
\newline%
|
|
223 |
\verb|end; (*struct Example*)|%
|
|
224 |
\end{isamarkuptext}%
|
|
225 |
\isamarkuptrue%
|
|
226 |
%
|
|
227 |
\endisatagquoteme
|
|
228 |
{\isafoldquoteme}%
|
|
229 |
%
|
|
230 |
\isadelimquoteme
|
|
231 |
%
|
|
232 |
\endisadelimquoteme
|
|
233 |
%
|
|
234 |
\begin{isamarkuptext}%
|
|
235 |
\noindent This still is not perfect: the parentheses
|
|
236 |
around the \qt{andalso} expression are superfluous.
|
|
237 |
Though the serializer
|
|
238 |
by no means attempts to imitate the rich Isabelle syntax
|
|
239 |
framework, it provides some common idioms, notably
|
|
240 |
associative infixes with precedences which may be used here:%
|
|
241 |
\end{isamarkuptext}%
|
|
242 |
\isamarkuptrue%
|
|
243 |
%
|
|
244 |
\isadelimtt
|
|
245 |
%
|
|
246 |
\endisadelimtt
|
|
247 |
%
|
|
248 |
\isatagtt
|
|
249 |
\isacommand{code{\isacharunderscore}const}\isamarkupfalse%
|
|
250 |
\ {\isachardoublequoteopen}op\ {\isasymand}{\isachardoublequoteclose}\isanewline
|
|
251 |
\ \ {\isacharparenleft}SML\ \isakeyword{infixl}\ {\isadigit{1}}\ {\isachardoublequoteopen}andalso{\isachardoublequoteclose}{\isacharparenright}%
|
|
252 |
\endisatagtt
|
|
253 |
{\isafoldtt}%
|
|
254 |
%
|
|
255 |
\isadelimtt
|
|
256 |
%
|
|
257 |
\endisadelimtt
|
|
258 |
%
|
|
259 |
\isadelimquoteme
|
|
260 |
%
|
|
261 |
\endisadelimquoteme
|
|
262 |
%
|
|
263 |
\isatagquoteme
|
|
264 |
%
|
|
265 |
\begin{isamarkuptext}%
|
|
266 |
\isaverbatim%
|
|
267 |
\noindent%
|
|
268 |
\verb|structure Example = |\newline%
|
|
269 |
\verb|struct|\newline%
|
|
270 |
\newline%
|
|
271 |
\verb|datatype nat = Suc of nat |\verb,|,\verb| Zero_nat;|\newline%
|
|
272 |
\newline%
|
|
273 |
\verb|fun less_nat m (Suc n) = less_eq_nat m n|\newline%
|
|
274 |
\verb| |\verb,|,\verb| less_nat n Zero_nat = false|\newline%
|
|
275 |
\verb|and less_eq_nat (Suc m) n = less_nat m n|\newline%
|
|
276 |
\verb| |\verb,|,\verb| less_eq_nat Zero_nat n = true;|\newline%
|
|
277 |
\newline%
|
|
278 |
\verb|fun in_interval (k, l) n = less_eq_nat k n andalso less_eq_nat n l;|\newline%
|
|
279 |
\newline%
|
|
280 |
\verb|end; (*struct Example*)|%
|
|
281 |
\end{isamarkuptext}%
|
|
282 |
\isamarkuptrue%
|
|
283 |
%
|
|
284 |
\endisatagquoteme
|
|
285 |
{\isafoldquoteme}%
|
|
286 |
%
|
|
287 |
\isadelimquoteme
|
|
288 |
%
|
|
289 |
\endisadelimquoteme
|
|
290 |
%
|
|
291 |
\begin{isamarkuptext}%
|
|
292 |
\noindent Next, we try to map HOL pairs to SML pairs, using the
|
|
293 |
infix ``\verb|*|'' type constructor and parentheses:%
|
|
294 |
\end{isamarkuptext}%
|
|
295 |
\isamarkuptrue%
|
|
296 |
%
|
|
297 |
\isadeliminvisible
|
|
298 |
%
|
|
299 |
\endisadeliminvisible
|
|
300 |
%
|
|
301 |
\isataginvisible
|
|
302 |
%
|
|
303 |
\endisataginvisible
|
|
304 |
{\isafoldinvisible}%
|
|
305 |
%
|
|
306 |
\isadeliminvisible
|
|
307 |
%
|
|
308 |
\endisadeliminvisible
|
|
309 |
%
|
|
310 |
\isadelimtt
|
|
311 |
%
|
|
312 |
\endisadelimtt
|
|
313 |
%
|
|
314 |
\isatagtt
|
|
315 |
\isacommand{code{\isacharunderscore}type}\isamarkupfalse%
|
|
316 |
\ {\isacharasterisk}\isanewline
|
|
317 |
\ \ {\isacharparenleft}SML\ \isakeyword{infix}\ {\isadigit{2}}\ {\isachardoublequoteopen}{\isacharasterisk}{\isachardoublequoteclose}{\isacharparenright}\isanewline
|
|
318 |
\isacommand{code{\isacharunderscore}const}\isamarkupfalse%
|
|
319 |
\ Pair\isanewline
|
|
320 |
\ \ {\isacharparenleft}SML\ {\isachardoublequoteopen}{\isacharbang}{\isacharparenleft}{\isacharparenleft}{\isacharunderscore}{\isacharparenright}{\isacharcomma}{\isacharslash}\ {\isacharparenleft}{\isacharunderscore}{\isacharparenright}{\isacharparenright}{\isachardoublequoteclose}{\isacharparenright}%
|
|
321 |
\endisatagtt
|
|
322 |
{\isafoldtt}%
|
|
323 |
%
|
|
324 |
\isadelimtt
|
|
325 |
%
|
|
326 |
\endisadelimtt
|
|
327 |
%
|
|
328 |
\begin{isamarkuptext}%
|
|
329 |
\noindent The initial bang ``\verb|!|'' tells the serializer to never put
|
|
330 |
parentheses around the whole expression (they are already present),
|
|
331 |
while the parentheses around argument place holders
|
|
332 |
tell not to put parentheses around the arguments.
|
|
333 |
The slash ``\verb|/|'' (followed by arbitrary white space)
|
|
334 |
inserts a space which may be used as a break if necessary
|
|
335 |
during pretty printing.
|
|
336 |
|
|
337 |
These examples give a glimpse what mechanisms
|
|
338 |
custom serialisations provide; however their usage
|
|
339 |
requires careful thinking in order not to introduce
|
|
340 |
inconsistencies -- or, in other words:
|
|
341 |
custom serialisations are completely axiomatic.
|
|
342 |
|
|
343 |
A further noteworthy details is that any special
|
|
344 |
character in a custom serialisation may be quoted
|
|
345 |
using ``\verb|'|''; thus, in
|
|
346 |
``\verb|fn '_ => _|'' the first
|
|
347 |
``\verb|_|'' is a proper underscore while the
|
|
348 |
second ``\verb|_|'' is a placeholder.
|
|
349 |
|
|
350 |
The HOL theories provide further
|
|
351 |
examples for custom serialisations.%
|
|
352 |
\end{isamarkuptext}%
|
|
353 |
\isamarkuptrue%
|
|
354 |
%
|
|
355 |
\isamarkupsubsection{\isa{Haskell} serialisation%
|
|
356 |
}
|
|
357 |
\isamarkuptrue%
|
|
358 |
%
|
|
359 |
\begin{isamarkuptext}%
|
|
360 |
For convenience, the default
|
|
361 |
\isa{HOL} setup for \isa{Haskell} maps the \isa{eq} class to
|
|
362 |
its counterpart in \isa{Haskell}, giving custom serialisations
|
|
363 |
for the class \isa{eq} (by command \hyperlink{command.code-class}{\mbox{\isa{\isacommand{code{\isacharunderscore}class}}}}) and its operation
|
|
364 |
\isa{eq{\isacharunderscore}class{\isachardot}eq}%
|
|
365 |
\end{isamarkuptext}%
|
|
366 |
\isamarkuptrue%
|
|
367 |
%
|
|
368 |
\isadelimtt
|
|
369 |
%
|
|
370 |
\endisadelimtt
|
|
371 |
%
|
|
372 |
\isatagtt
|
|
373 |
\isacommand{code{\isacharunderscore}class}\isamarkupfalse%
|
|
374 |
\ eq\isanewline
|
|
375 |
\ \ {\isacharparenleft}Haskell\ {\isachardoublequoteopen}Eq{\isachardoublequoteclose}\ \isakeyword{where}\ {\isachardoublequoteopen}HOL{\isachardot}eq{\isachardoublequoteclose}\ {\isasymequiv}\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharequal}{\isacharequal}{\isacharparenright}{\isachardoublequoteclose}{\isacharparenright}\isanewline
|
|
376 |
\isanewline
|
|
377 |
\isacommand{code{\isacharunderscore}const}\isamarkupfalse%
|
|
378 |
\ {\isachardoublequoteopen}op\ {\isacharequal}{\isachardoublequoteclose}\isanewline
|
|
379 |
\ \ {\isacharparenleft}Haskell\ \isakeyword{infixl}\ {\isadigit{4}}\ {\isachardoublequoteopen}{\isacharequal}{\isacharequal}{\isachardoublequoteclose}{\isacharparenright}%
|
|
380 |
\endisatagtt
|
|
381 |
{\isafoldtt}%
|
|
382 |
%
|
|
383 |
\isadelimtt
|
|
384 |
%
|
|
385 |
\endisadelimtt
|
|
386 |
%
|
|
387 |
\begin{isamarkuptext}%
|
|
388 |
\noindent A problem now occurs whenever a type which
|
|
389 |
is an instance of \isa{eq} in \isa{HOL} is mapped
|
|
390 |
on a \isa{Haskell}-built-in type which is also an instance
|
|
391 |
of \isa{Haskell} \isa{Eq}:%
|
|
392 |
\end{isamarkuptext}%
|
|
393 |
\isamarkuptrue%
|
|
394 |
%
|
|
395 |
\isadelimquoteme
|
|
396 |
%
|
|
397 |
\endisadelimquoteme
|
|
398 |
%
|
|
399 |
\isatagquoteme
|
|
400 |
\isacommand{typedecl}\isamarkupfalse%
|
|
401 |
\ bar\isanewline
|
|
402 |
\isanewline
|
|
403 |
\isacommand{instantiation}\isamarkupfalse%
|
|
404 |
\ bar\ {\isacharcolon}{\isacharcolon}\ eq\isanewline
|
|
405 |
\isakeyword{begin}\isanewline
|
|
406 |
\isanewline
|
|
407 |
\isacommand{definition}\isamarkupfalse%
|
|
408 |
\ {\isachardoublequoteopen}eq{\isacharunderscore}class{\isachardot}eq\ {\isacharparenleft}x{\isasymColon}bar{\isacharparenright}\ y\ {\isasymlongleftrightarrow}\ x\ {\isacharequal}\ y{\isachardoublequoteclose}\isanewline
|
|
409 |
\isanewline
|
|
410 |
\isacommand{instance}\isamarkupfalse%
|
|
411 |
\ \isacommand{by}\isamarkupfalse%
|
|
412 |
\ default\ {\isacharparenleft}simp\ add{\isacharcolon}\ eq{\isacharunderscore}bar{\isacharunderscore}def{\isacharparenright}\isanewline
|
|
413 |
\isanewline
|
|
414 |
\isacommand{end}\isamarkupfalse%
|
|
415 |
%
|
|
416 |
\endisatagquoteme
|
|
417 |
{\isafoldquoteme}%
|
|
418 |
%
|
|
419 |
\isadelimquoteme
|
|
420 |
%
|
|
421 |
\endisadelimquoteme
|
|
422 |
\isanewline
|
|
423 |
%
|
|
424 |
\isadelimtt
|
|
425 |
\isanewline
|
|
426 |
%
|
|
427 |
\endisadelimtt
|
|
428 |
%
|
|
429 |
\isatagtt
|
|
430 |
\isacommand{code{\isacharunderscore}type}\isamarkupfalse%
|
|
431 |
\ bar\isanewline
|
|
432 |
\ \ {\isacharparenleft}Haskell\ {\isachardoublequoteopen}Integer{\isachardoublequoteclose}{\isacharparenright}%
|
|
433 |
\endisatagtt
|
|
434 |
{\isafoldtt}%
|
|
435 |
%
|
|
436 |
\isadelimtt
|
|
437 |
%
|
|
438 |
\endisadelimtt
|
|
439 |
%
|
|
440 |
\begin{isamarkuptext}%
|
|
441 |
\noindent The code generator would produce
|
|
442 |
an additional instance, which of course is rejectedby the \isa{Haskell}
|
|
443 |
compiler.
|
|
444 |
To suppress this additional instance, use
|
|
445 |
\isa{code{\isacharunderscore}instance}:%
|
|
446 |
\end{isamarkuptext}%
|
|
447 |
\isamarkuptrue%
|
|
448 |
%
|
|
449 |
\isadelimtt
|
|
450 |
%
|
|
451 |
\endisadelimtt
|
|
452 |
%
|
|
453 |
\isatagtt
|
|
454 |
\isacommand{code{\isacharunderscore}instance}\isamarkupfalse%
|
|
455 |
\ bar\ {\isacharcolon}{\isacharcolon}\ eq\isanewline
|
|
456 |
\ \ {\isacharparenleft}Haskell\ {\isacharminus}{\isacharparenright}%
|
|
457 |
\endisatagtt
|
|
458 |
{\isafoldtt}%
|
|
459 |
%
|
|
460 |
\isadelimtt
|
|
461 |
%
|
|
462 |
\endisadelimtt
|
|
463 |
\isanewline
|
|
464 |
%
|
|
465 |
\isadelimtheory
|
|
466 |
\isanewline
|
|
467 |
%
|
|
468 |
\endisadelimtheory
|
|
469 |
%
|
|
470 |
\isatagtheory
|
|
471 |
\isacommand{end}\isamarkupfalse%
|
|
472 |
%
|
|
473 |
\endisatagtheory
|
|
474 |
{\isafoldtheory}%
|
|
475 |
%
|
|
476 |
\isadelimtheory
|
|
477 |
%
|
|
478 |
\endisadelimtheory
|
|
479 |
\isanewline
|
|
480 |
\end{isabellebody}%
|
|
481 |
%%% Local Variables:
|
|
482 |
%%% mode: latex
|
|
483 |
%%% TeX-master: "root"
|
|
484 |
%%% End:
|