doc-src/Codegen/Thy/document/Adaptation.tex
author bulwahn
Tue, 08 May 2012 14:31:03 +0200
changeset 47893 4cf901b1089a
parent 46563 0ad69b30b39c
permissions -rw-r--r--
specialised fact in the Record theory should not be appear in proofs discovered by sledgehammer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     1
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     2
\begin{isabellebody}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     3
\def\isabellecontext{Adaptation}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     4
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     5
\isadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     6
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     7
\endisadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     8
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
     9
\isatagtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    10
\isacommand{theory}\isamarkupfalse%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    11
\ Adaptation\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    12
\isakeyword{imports}\ Setup\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    13
\isakeyword{begin}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    14
\endisatagtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    15
{\isafoldtheory}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    16
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    17
\isadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    18
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    19
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    20
\endisadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    21
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    22
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    23
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    24
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    25
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    26
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    27
\isataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    28
\isacommand{setup}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
    29
\ {\isaliteral{7B2A}{\isacharverbatimopen}}\ Code{\isaliteral{5F}{\isacharunderscore}}Target{\isaliteral{2E}{\isachardot}}extend{\isaliteral{5F}{\isacharunderscore}}target\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C534D4C3E}{\isasymSML}}{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}SML{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2C}{\isacharcomma}}\ K\ I{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
    30
\ \ {\isaliteral{23}{\isacharhash}}{\isaliteral{3E}{\isachargreater}}\ Code{\isaliteral{5F}{\isacharunderscore}}Target{\isaliteral{2E}{\isachardot}}extend{\isaliteral{5F}{\isacharunderscore}}target\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C534D4C64756D6D793E}{\isasymSMLdummy}}{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}Haskell{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2C}{\isacharcomma}}\ K\ I{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{2A7D}{\isacharverbatimclose}}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    31
\endisataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    32
{\isafoldinvisible}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    33
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    34
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    35
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    36
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    37
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    38
\isamarkupsection{Adaptation to target languages \label{sec:adaptation}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    39
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    40
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    41
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    42
\isamarkupsubsection{Adapting code generation%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    43
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    44
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    45
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    46
\begin{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    47
The aspects of code generation introduced so far have two aspects
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    48
  in common:
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    49
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    50
  \begin{itemize}
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    51
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    52
    \item They act uniformly, without reference to a specific target
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    53
       language.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    54
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    55
    \item They are \emph{safe} in the sense that as long as you trust
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    56
       the code generator meta theory and implementation, you cannot
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    57
       produce programs that yield results which are not derivable in
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    58
       the logic.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    59
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    60
  \end{itemize}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    61
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    62
  \noindent In this section we will introduce means to \emph{adapt}
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    63
  the serialiser to a specific target language, i.e.~to print program
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    64
  fragments in a way which accommodates \qt{already existing}
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    65
  ingredients of a target language environment, for three reasons:
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    66
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    67
  \begin{itemize}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    68
    \item improving readability and aesthetics of generated code
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    69
    \item gaining efficiency
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    70
    \item interface with language parts which have no direct counterpart
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    71
      in \isa{HOL} (say, imperative data structures)
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    72
  \end{itemize}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    73
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    74
  \noindent Generally, you should avoid using those features yourself
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    75
  \emph{at any cost}:
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    76
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    77
  \begin{itemize}
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    78
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    79
    \item The safe configuration methods act uniformly on every target
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    80
      language, whereas for adaptation you have to treat each target
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    81
      language separately.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    82
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    83
    \item Application is extremely tedious since there is no
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    84
      abstraction which would allow for a static check, making it easy
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    85
      to produce garbage.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    86
34155
14aaccb399b3 Polishing up the English
paulson
parents: 33707
diff changeset
    87
    \item Subtle errors can be introduced unconsciously.
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    88
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    89
  \end{itemize}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    90
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    91
  \noindent However, even if you ought refrain from setting up
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    92
  adaptation yourself, already the \isa{HOL} comes with some
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    93
  reasonable default adaptations (say, using target language list
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    94
  syntax).  There also some common adaptation cases which you can
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    95
  setup by importing particular library theories.  In order to
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    96
  understand these, we provide some clues here; these however are not
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
    97
  supposed to replace a careful study of the sources.%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    98
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
    99
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   100
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   101
\isamarkupsubsection{The adaptation principle%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   102
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   103
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   104
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   105
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   106
Figure \ref{fig:adaptation} illustrates what \qt{adaptation} is
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   107
  conceptually supposed to be:
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   108
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   109
  \begin{figure}[here]
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   110
    \includegraphics{adaptation}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   111
    \caption{The adaptation principle}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   112
    \label{fig:adaptation}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   113
  \end{figure}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   114
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   115
  \noindent In the tame view, code generation acts as broker between
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   116
  \isa{logic}, \isa{intermediate\ language} and \isa{target\ language} by means of \isa{translation} and \isa{serialisation}; for the latter, the serialiser has to observe the
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   117
  structure of the \isa{language} itself plus some \isa{reserved}
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   118
  keywords which have to be avoided for generated code.  However, if
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   119
  you consider \isa{adaptation} mechanisms, the code generated by
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   120
  the serializer is just the tip of the iceberg:
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   121
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   122
  \begin{itemize}
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   123
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   124
    \item \isa{serialisation} can be \emph{parametrised} such that
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   125
      logical entities are mapped to target-specific ones
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   126
      (e.g. target-specific list syntax, see also
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   127
      \secref{sec:adaptation_mechanisms})
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   128
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   129
    \item Such parametrisations can involve references to a
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   130
      target-specific standard \isa{library} (e.g. using the \isa{Haskell} \verb|Maybe| type instead of the \isa{HOL}
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   131
      \isa{option} type); if such are used, the corresponding
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   132
      identifiers (in our example, \verb|Maybe|, \verb|Nothing| and \verb|Just|) also have to be considered \isa{reserved}.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   133
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   134
    \item Even more, the user can enrich the library of the
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   135
      target-language by providing code snippets (\qt{\isa{includes}}) which are prepended to any generated code (see
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   136
      \secref{sec:include}); this typically also involves further
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   137
      \isa{reserved} identifiers.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   138
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   139
  \end{itemize}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   140
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   141
  \noindent As figure \ref{fig:adaptation} illustrates, all these
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   142
  adaptation mechanisms have to act consistently; it is at the
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   143
  discretion of the user to take care for this.%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   144
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   145
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   146
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   147
\isamarkupsubsection{Common adaptation patterns%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   148
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   149
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   150
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   151
\begin{isamarkuptext}%
46563
0ad69b30b39c updated generated files (cf. 8d51b375e926);
wenzelm
parents: 46523
diff changeset
   152
The \isa{HOL} \isa{Main} theory already provides a code
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   153
  generator setup which should be suitable for most applications.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   154
  Common extensions and modifications are available by certain
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   155
  theories of the \isa{HOL} library; beside being useful in
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   156
  applications, they may serve as a tutorial for customising the code
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   157
  generator setup (see below \secref{sec:adaptation_mechanisms}).
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   158
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   159
  \begin{description}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   160
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   161
    \item[\isa{Code{\isaliteral{5F}{\isacharunderscore}}Integer}] represents \isa{HOL} integers by
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   162
       big integer literals in target languages.
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   163
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   164
    \item[\isa{Code{\isaliteral{5F}{\isacharunderscore}}Char}] represents \isa{HOL} characters by
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   165
       character literals in target languages.
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   166
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   167
    \item[\isa{Code{\isaliteral{5F}{\isacharunderscore}}Char{\isaliteral{5F}{\isacharunderscore}}chr}] like \isa{Code{\isaliteral{5F}{\isacharunderscore}}Char}, but
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   168
       also offers treatment of character codes; includes \isa{Code{\isaliteral{5F}{\isacharunderscore}}Char}.
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   169
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   170
    \item[\isa{Efficient{\isaliteral{5F}{\isacharunderscore}}Nat}] \label{eff_nat} implements
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   171
       natural numbers by integers, which in general will result in
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   172
       higher efficiency; pattern matching with \isa{{\isadigit{0}}} /
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   173
       \isa{Suc} is eliminated; includes \isa{Code{\isaliteral{5F}{\isacharunderscore}}Integer}
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   174
       and \isa{Code{\isaliteral{5F}{\isacharunderscore}}Numeral}.
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   175
46563
0ad69b30b39c updated generated files (cf. 8d51b375e926);
wenzelm
parents: 46523
diff changeset
   176
    \item[\isa{Code{\isaliteral{5F}{\isacharunderscore}}Numeral}] provides an additional datatype
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   177
       \isa{index} which is mapped to target-language built-in
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   178
       integers.  Useful for code setups which involve e.g.~indexing
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   179
       of target-language arrays.  Part of \isa{HOL{\isaliteral{2D}{\isacharminus}}Main}.
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   180
46563
0ad69b30b39c updated generated files (cf. 8d51b375e926);
wenzelm
parents: 46523
diff changeset
   181
    \item[\isa{String}] provides an additional datatype \isa{String{\isaliteral{2E}{\isachardot}}literal} which is isomorphic to strings; \isa{String{\isaliteral{2E}{\isachardot}}literal}s are mapped to target-language strings.  Useful
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   182
       for code setups which involve e.g.~printing (error) messages.
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   183
       Part of \isa{HOL{\isaliteral{2D}{\isacharminus}}Main}.
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   184
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   185
  \end{description}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   186
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   187
  \begin{warn}
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   188
    When importing any of those theories which are not part of
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   189
    \isa{HOL{\isaliteral{2D}{\isacharminus}}Main}, they should form the last
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   190
    items in an import list.  Since these theories adapt the code
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   191
    generator setup in a non-conservative fashion, strange effects may
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   192
    occur otherwise.
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   193
  \end{warn}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   194
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   195
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   196
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   197
\isamarkupsubsection{Parametrising serialisation \label{sec:adaptation_mechanisms}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   198
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   199
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   200
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   201
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   202
Consider the following function and its corresponding SML code:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   203
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   204
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   205
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   206
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   207
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   208
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   209
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   210
\isatagquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   211
\isacommand{primrec}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   212
\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{22}{\isachardoublequoteopen}}nat\ {\isaliteral{5C3C74696D65733E}{\isasymtimes}}\ nat\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ nat\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{22}{\isachardoublequoteclose}}\ \isakeyword{where}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   213
\ \ {\isaliteral{22}{\isachardoublequoteopen}}in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{28}{\isacharparenleft}}k{\isaliteral{2C}{\isacharcomma}}\ l{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ k\ {\isaliteral{5C3C6C653E}{\isasymle}}\ n\ {\isaliteral{5C3C616E643E}{\isasymand}}\ n\ {\isaliteral{5C3C6C653E}{\isasymle}}\ l{\isaliteral{22}{\isachardoublequoteclose}}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   214
\endisatagquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   215
{\isafoldquote}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   216
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   217
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   218
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   219
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   220
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   221
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   222
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   223
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   224
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   225
\isataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   226
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   227
\endisataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   228
{\isafoldinvisible}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   229
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   230
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   231
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   232
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   233
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   234
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   235
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   236
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   237
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   238
\isatagquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   239
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   240
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   241
structure\ Example\ {\isaliteral{3A}{\isacharcolon}}\ sig\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   242
\ \ datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   243
\ \ datatype\ boola\ {\isaliteral{3D}{\isacharequal}}\ True\ {\isaliteral{7C}{\isacharbar}}\ False\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   244
\ \ val\ conj\ {\isaliteral{3A}{\isacharcolon}}\ boola\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ boola\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ boola\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   245
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ boola\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   246
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ boola\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   247
\ \ val\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2A}{\isacharasterisk}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ boola\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   248
end\ {\isaliteral{3D}{\isacharequal}}\ struct\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   249
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   250
datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   251
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   252
datatype\ boola\ {\isaliteral{3D}{\isacharequal}}\ True\ {\isaliteral{7C}{\isacharbar}}\ False{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   253
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   254
fun\ conj\ p\ True\ {\isaliteral{3D}{\isacharequal}}\ p\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   255
\ \ {\isaliteral{7C}{\isacharbar}}\ conj\ p\ False\ {\isaliteral{3D}{\isacharequal}}\ False\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   256
\ \ {\isaliteral{7C}{\isacharbar}}\ conj\ True\ p\ {\isaliteral{3D}{\isacharequal}}\ p\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   257
\ \ {\isaliteral{7C}{\isacharbar}}\ conj\ False\ p\ {\isaliteral{3D}{\isacharequal}}\ False{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   258
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   259
fun\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ {\isaliteral{28}{\isacharparenleft}}Suc\ n{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   260
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ n\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3D}{\isacharequal}}\ False\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   261
and\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{28}{\isacharparenleft}}Suc\ m{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   262
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ n\ {\isaliteral{3D}{\isacharequal}}\ True{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   263
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   264
fun\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{28}{\isacharparenleft}}k{\isaliteral{2C}{\isacharcomma}}\ l{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ conj\ {\isaliteral{28}{\isacharparenleft}}less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ k\ n{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{28}{\isacharparenleft}}less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ n\ l{\isaliteral{29}{\isacharparenright}}{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   265
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   266
end{\isaliteral{3B}{\isacharsemicolon}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{2A}{\isacharasterisk}}struct\ Example{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{29}{\isacharparenright}}\isanewline%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   267
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   268
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   269
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   270
\endisatagquotetypewriter
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   271
{\isafoldquotetypewriter}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   272
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   273
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   274
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   275
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   276
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   277
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   278
\noindent Though this is correct code, it is a little bit
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   279
  unsatisfactory: boolean values and operators are materialised as
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   280
  distinguished entities with have nothing to do with the SML-built-in
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   281
  notion of \qt{bool}.  This results in less readable code;
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   282
  additionally, eager evaluation may cause programs to loop or break
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   283
  which would perfectly terminate when the existing SML \verb|bool| would be used.  To map the HOL \isa{bool} on SML \verb|bool|, we may use \qn{custom serialisations}:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   284
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   285
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   286
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   287
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   288
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   289
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   290
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   291
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   292
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}\isamarkupfalse%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   293
\ bool\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   294
\ \ {\isaliteral{28}{\isacharparenleft}}SML\ {\isaliteral{22}{\isachardoublequoteopen}}bool{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   295
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   296
\ True\ \isakeyword{and}\ False\ \isakeyword{and}\ {\isaliteral{22}{\isachardoublequoteopen}}op\ {\isaliteral{5C3C616E643E}{\isasymand}}{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   297
\ \ {\isaliteral{28}{\isacharparenleft}}SML\ {\isaliteral{22}{\isachardoublequoteopen}}true{\isaliteral{22}{\isachardoublequoteclose}}\ \isakeyword{and}\ {\isaliteral{22}{\isachardoublequoteopen}}false{\isaliteral{22}{\isachardoublequoteclose}}\ \isakeyword{and}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{5F}{\isacharunderscore}}\ andalso\ {\isaliteral{5F}{\isacharunderscore}}{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   298
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   299
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   300
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   301
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   302
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   303
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   304
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   305
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   306
\noindent The \indexdef{}{command}{code\_type}\hypertarget{command.code-type}{\hyperlink{command.code-type}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}}}}} command takes a type constructor
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   307
  as arguments together with a list of custom serialisations.  Each
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   308
  custom serialisation starts with a target language identifier
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   309
  followed by an expression, which during code serialisation is
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   310
  inserted whenever the type constructor would occur.  For constants,
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   311
  \indexdef{}{command}{code\_const}\hypertarget{command.code-const}{\hyperlink{command.code-const}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}}}}} implements the corresponding mechanism.  Each
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   312
  ``\verb|_|'' in a serialisation expression is treated as a
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   313
  placeholder for the type constructor's (the constant's) arguments.%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   314
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   315
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   316
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   317
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   318
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   319
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   320
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   321
\isatagquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   322
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   323
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   324
structure\ Example\ {\isaliteral{3A}{\isacharcolon}}\ sig\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   325
\ \ datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   326
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   327
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   328
\ \ val\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2A}{\isacharasterisk}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   329
end\ {\isaliteral{3D}{\isacharequal}}\ struct\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   330
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   331
datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   332
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   333
fun\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ {\isaliteral{28}{\isacharparenleft}}Suc\ n{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   334
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ n\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3D}{\isacharequal}}\ false\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   335
and\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{28}{\isacharparenleft}}Suc\ m{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   336
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ n\ {\isaliteral{3D}{\isacharequal}}\ true{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   337
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   338
fun\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{28}{\isacharparenleft}}k{\isaliteral{2C}{\isacharcomma}}\ l{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{28}{\isacharparenleft}}less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ k\ n{\isaliteral{29}{\isacharparenright}}\ andalso\ {\isaliteral{28}{\isacharparenleft}}less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ n\ l{\isaliteral{29}{\isacharparenright}}{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   339
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   340
end{\isaliteral{3B}{\isacharsemicolon}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{2A}{\isacharasterisk}}struct\ Example{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{29}{\isacharparenright}}\isanewline%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   341
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   342
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   343
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   344
\endisatagquotetypewriter
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   345
{\isafoldquotetypewriter}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   346
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   347
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   348
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   349
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   350
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   351
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   352
\noindent This still is not perfect: the parentheses around the
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   353
  \qt{andalso} expression are superfluous.  Though the serialiser by
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   354
  no means attempts to imitate the rich Isabelle syntax framework, it
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   355
  provides some common idioms, notably associative infixes with
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   356
  precedences which may be used here:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   357
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   358
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   359
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   360
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   361
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   362
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   363
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   364
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   365
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   366
\ {\isaliteral{22}{\isachardoublequoteopen}}op\ {\isaliteral{5C3C616E643E}{\isasymand}}{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   367
\ \ {\isaliteral{28}{\isacharparenleft}}SML\ \isakeyword{infixl}\ {\isadigit{1}}\ {\isaliteral{22}{\isachardoublequoteopen}}andalso{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   368
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   369
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   370
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   371
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   372
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   373
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   374
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   375
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   376
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   377
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   378
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   379
\isatagquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   380
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   381
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   382
structure\ Example\ {\isaliteral{3A}{\isacharcolon}}\ sig\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   383
\ \ datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   384
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   385
\ \ val\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   386
\ \ val\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{2A}{\isacharasterisk}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ nat\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{3E}{\isachargreater}}\ bool\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   387
end\ {\isaliteral{3D}{\isacharequal}}\ struct\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   388
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   389
datatype\ nat\ {\isaliteral{3D}{\isacharequal}}\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{7C}{\isacharbar}}\ Suc\ of\ nat{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   390
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   391
fun\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ {\isaliteral{28}{\isacharparenleft}}Suc\ n{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   392
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ n\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{3D}{\isacharequal}}\ false\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   393
and\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ {\isaliteral{28}{\isacharparenleft}}Suc\ m{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}nat\ m\ n\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   394
\ \ {\isaliteral{7C}{\isacharbar}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ Zero{\isaliteral{5F}{\isacharunderscore}}nat\ n\ {\isaliteral{3D}{\isacharequal}}\ true{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   395
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   396
fun\ in{\isaliteral{5F}{\isacharunderscore}}interval\ {\isaliteral{28}{\isacharparenleft}}k{\isaliteral{2C}{\isacharcomma}}\ l{\isaliteral{29}{\isacharparenright}}\ n\ {\isaliteral{3D}{\isacharequal}}\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ k\ n\ andalso\ less{\isaliteral{5F}{\isacharunderscore}}eq{\isaliteral{5F}{\isacharunderscore}}nat\ n\ l{\isaliteral{3B}{\isacharsemicolon}}\isanewline
39664
0afaf89ab591 more canonical type setting of type writer code examples
haftmann
parents: 39643
diff changeset
   397
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   398
end{\isaliteral{3B}{\isacharsemicolon}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{2A}{\isacharasterisk}}struct\ Example{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{29}{\isacharparenright}}\isanewline%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   399
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   400
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   401
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   402
\endisatagquotetypewriter
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   403
{\isafoldquotetypewriter}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   404
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   405
\isadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   406
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   407
\endisadelimquotetypewriter
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   408
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   409
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   410
\noindent The attentive reader may ask how we assert that no
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   411
  generated code will accidentally overwrite.  For this reason the
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   412
  serialiser has an internal table of identifiers which have to be
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   413
  avoided to be used for new declarations.  Initially, this table
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   414
  typically contains the keywords of the target language.  It can be
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   415
  extended manually, thus avoiding accidental overwrites, using the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   416
  \indexdef{}{command}{code\_reserved}\hypertarget{command.code-reserved}{\hyperlink{command.code-reserved}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}}}}} command:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   417
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   418
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   419
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   420
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   421
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   422
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   423
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   424
\isatagquote
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   425
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   426
\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{5C3C534D4C64756D6D793E}{\isasymSMLdummy}}{\isaliteral{22}{\isachardoublequoteclose}}\ bool\ true\ false\ andalso%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   427
\endisatagquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   428
{\isafoldquote}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   429
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   430
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   431
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   432
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   433
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   434
\begin{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   435
\noindent Next, we try to map HOL pairs to SML pairs, using the
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   436
  infix ``\verb|*|'' type constructor and parentheses:%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   437
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   438
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   439
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   440
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   441
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   442
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   443
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   444
\isataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   445
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   446
\endisataginvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   447
{\isafoldinvisible}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   448
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   449
\isadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   450
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   451
\endisadeliminvisible
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   452
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   453
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   454
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   455
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   456
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   457
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   458
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}\isamarkupfalse%
37836
2bcce92be291 adjusted; fixed typo
haftmann
parents: 34179
diff changeset
   459
\ prod\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   460
\ \ {\isaliteral{28}{\isacharparenleft}}SML\ \isakeyword{infix}\ {\isadigit{2}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   461
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}\isamarkupfalse%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   462
\ Pair\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   463
\ \ {\isaliteral{28}{\isacharparenleft}}SML\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{21}{\isacharbang}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5F}{\isacharunderscore}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}{\isaliteral{2F}{\isacharslash}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5F}{\isacharunderscore}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   464
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   465
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   466
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   467
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   468
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   469
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   470
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   471
\begin{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   472
\noindent The initial bang ``\verb|!|'' tells the serialiser
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   473
  never to put parentheses around the whole expression (they are
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   474
  already present), while the parentheses around argument place
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   475
  holders tell not to put parentheses around the arguments.  The slash
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   476
  ``\verb|/|'' (followed by arbitrary white space) inserts a
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   477
  space which may be used as a break if necessary during pretty
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   478
  printing.
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   479
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   480
  These examples give a glimpse what mechanisms custom serialisations
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   481
  provide; however their usage requires careful thinking in order not
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   482
  to introduce inconsistencies -- or, in other words: custom
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   483
  serialisations are completely axiomatic.
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   484
39643
29cc021398fc corrections and tuning
haftmann
parents: 39068
diff changeset
   485
  A further noteworthy detail is that any special character in a
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   486
  custom serialisation may be quoted using ``\verb|'|''; thus,
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   487
  in ``\verb|fn '_ => _|'' the first ``\verb|_|'' is a
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   488
  proper underscore while the second ``\verb|_|'' is a
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   489
  placeholder.%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   490
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   491
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   492
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   493
\isamarkupsubsection{\isa{Haskell} serialisation%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   494
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   495
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   496
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   497
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   498
For convenience, the default \isa{HOL} setup for \isa{Haskell}
39068
5ac590e8b320 updated
haftmann
parents: 38813
diff changeset
   499
  maps the \isa{equal} class to its counterpart in \isa{Haskell},
5ac590e8b320 updated
haftmann
parents: 38813
diff changeset
   500
  giving custom serialisations for the class \isa{equal} (by command
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   501
  \indexdef{}{command}{code\_class}\hypertarget{command.code-class}{\hyperlink{command.code-class}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}}}}}) and its operation \isa{HOL{\isaliteral{2E}{\isachardot}}equal}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   502
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   503
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   504
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   505
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   506
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   507
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   508
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   509
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   510
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}\isamarkupfalse%
39068
5ac590e8b320 updated
haftmann
parents: 38813
diff changeset
   511
\ equal\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   512
\ \ {\isaliteral{28}{\isacharparenleft}}Haskell\ {\isaliteral{22}{\isachardoublequoteopen}}Eq{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   513
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   514
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   515
\ {\isaliteral{22}{\isachardoublequoteopen}}HOL{\isaliteral{2E}{\isachardot}}equal{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   516
\ \ {\isaliteral{28}{\isacharparenleft}}Haskell\ \isakeyword{infixl}\ {\isadigit{4}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{3D}{\isacharequal}}{\isaliteral{3D}{\isacharequal}}{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   517
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   518
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   519
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   520
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   521
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   522
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   523
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   524
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   525
\noindent A problem now occurs whenever a type which is an instance
39068
5ac590e8b320 updated
haftmann
parents: 38813
diff changeset
   526
  of \isa{equal} in \isa{HOL} is mapped on a \isa{Haskell}-built-in type which is also an instance of \isa{Haskell}
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   527
  \isa{Eq}:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   528
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   529
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   530
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   531
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   532
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   533
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   534
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   535
\isatagquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   536
\isacommand{typedecl}\isamarkupfalse%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   537
\ bar\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   538
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   539
\isacommand{instantiation}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   540
\ bar\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ equal\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   541
\isakeyword{begin}\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   542
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   543
\isacommand{definition}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   544
\ {\isaliteral{22}{\isachardoublequoteopen}}HOL{\isaliteral{2E}{\isachardot}}equal\ {\isaliteral{28}{\isacharparenleft}}x{\isaliteral{5C3C436F6C6F6E3E}{\isasymColon}}bar{\isaliteral{29}{\isacharparenright}}\ y\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ x\ {\isaliteral{3D}{\isacharequal}}\ y{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   545
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   546
\isacommand{instance}\isamarkupfalse%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   547
\ \isacommand{by}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   548
\ default\ {\isaliteral{28}{\isacharparenleft}}simp\ add{\isaliteral{3A}{\isacharcolon}}\ equal{\isaliteral{5F}{\isacharunderscore}}bar{\isaliteral{5F}{\isacharunderscore}}def{\isaliteral{29}{\isacharparenright}}\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   549
\isanewline
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   550
\isacommand{end}\isamarkupfalse%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   551
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   552
\endisatagquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   553
{\isafoldquote}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   554
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   555
\isadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   556
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   557
\endisadelimquote
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   558
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   559
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   560
\ %
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   561
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   562
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   563
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   564
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}\isamarkupfalse%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   565
\ bar\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   566
\ \ {\isaliteral{28}{\isacharparenleft}}Haskell\ {\isaliteral{22}{\isachardoublequoteopen}}Integer{\isaliteral{22}{\isachardoublequoteclose}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   567
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   568
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   569
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   570
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   571
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   572
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   573
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   574
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   575
\noindent The code generator would produce an additional instance,
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   576
  which of course is rejected by the \isa{Haskell} compiler.  To
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   577
  suppress this additional instance, use \indexdef{}{command}{code\_instance}\hypertarget{command.code-instance}{\hyperlink{command.code-instance}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}}}}}:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   578
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   579
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   580
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   581
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   582
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   583
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   584
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   585
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   586
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   587
\ bar\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ equal\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   588
\ \ {\isaliteral{28}{\isacharparenleft}}Haskell\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{29}{\isacharparenright}}%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   589
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   590
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   591
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   592
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   593
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   594
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   595
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   596
\isamarkupsubsection{Enhancing the target language context \label{sec:include}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   597
}
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   598
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   599
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   600
\begin{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   601
In rare cases it is necessary to \emph{enrich} the context of a
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   602
  target language; this is accomplished using the \indexdef{}{command}{code\_include}\hypertarget{command.code-include}{\hyperlink{command.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}}} command:%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   603
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   604
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   605
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   606
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   607
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   608
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   609
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   610
\isatagquotett
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   611
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   612
\ Haskell\ {\isaliteral{22}{\isachardoublequoteopen}}Errno{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   613
{\isaliteral{7B2A}{\isacharverbatimopen}}errno\ i\ {\isaliteral{3D}{\isacharequal}}\ error\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}Error\ number{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{22}{\isachardoublequote}}\ {\isaliteral{2B}{\isacharplus}}{\isaliteral{2B}{\isacharplus}}\ show\ i{\isaliteral{29}{\isacharparenright}}{\isaliteral{2A7D}{\isacharverbatimclose}}\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   614
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   615
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}\isamarkupfalse%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   616
\ Haskell\ Errno%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   617
\endisatagquotett
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   618
{\isafoldquotett}%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   619
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   620
\isadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   621
%
39745
3aa2bc9c5478 combine quote and typewriter/tt tag
haftmann
parents: 39712
diff changeset
   622
\endisadelimquotett
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   623
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   624
\begin{isamarkuptext}%
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   625
\noindent Such named \isa{include}s are then prepended to every
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   626
  generated code.  Inspect such code in order to find out how
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40351
diff changeset
   627
  \hyperlink{command.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}} behaves with respect to a particular
38450
ada5814c9d87 tuned whitespace
haftmann
parents: 37836
diff changeset
   628
  target language.%
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   629
\end{isamarkuptext}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   630
\isamarkuptrue%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   631
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   632
\isadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   633
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   634
\endisadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   635
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   636
\isatagtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   637
\isacommand{end}\isamarkupfalse%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   638
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   639
\endisatagtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   640
{\isafoldtheory}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   641
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   642
\isadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   643
%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   644
\endisadelimtheory
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   645
\isanewline
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   646
\isanewline
31050
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   647
\end{isabellebody}%
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   648
%%% Local Variables:
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   649
%%% mode: latex
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   650
%%% TeX-master: "root"
555b56b66fcf adaptation replaces adaption
haftmann
parents:
diff changeset
   651
%%% End: