ProgTutorial/Recipes/Antiquotes.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 19 Mar 2009 13:28:16 +0100
changeset 189 069d525f8f1d
parent 188 CookBook/Recipes/Antiquotes.thy@8939b8fd8603
child 191 0150cf5982ae
permissions -rw-r--r--
made more of the transition from "CookBook" to "ProgTutorial"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
theory Antiquotes
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
     3
imports "../Base"
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
begin
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
     7
section {* Useful Document Antiquotations *}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
text {*
188
8939b8fd8603 added lots of FIXMES
Christian Urban <urbanc@in.tum.de>
parents: 175
diff changeset
    10
  (FIXME: update to to new antiquotation setup)
8939b8fd8603 added lots of FIXMES
Christian Urban <urbanc@in.tum.de>
parents: 175
diff changeset
    11
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    12
  {\bf Problem:} 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    13
  How to keep your ML-code inside a document synchronised with the actual code?\smallskip
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    15
  {\bf Solution:} This can be achieved using document antiquotations.\smallskip
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    16
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    17
  Document antiquotations can be used for ensuring consistent type-setting of
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    18
  various entities in a document. They can also be used for sophisticated
65
c8e9a4f97916 tuned and added a section about creating keyword files
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    19
  \LaTeX-hacking. If you type @{text "Ctrl-c Ctrl-a h A"} inside ProofGeneral, you
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    20
  obtain a list of all currently available document antiquotations and their options.
153
c22b507e1407 general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    21
  You obtain the same list on the ML-level by typing
c22b507e1407 general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    22
c22b507e1407 general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    23
  @{ML [display,gray] "ThyOutput.print_antiquotations ()"}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    25
  Below we give the code for two additional document antiquotations that can
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    26
  be used to typeset ML-code and also to check whether the given code actually
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    27
  compiles. This provides a sanity check for the code and also allows one to
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    28
  keep documents in sync with other code, for example Isabelle.
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    29
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    30
  We first describe the antiquotation @{text "ML_checked"} with the syntax:
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    31
 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    32
  @{text [display] "@{ML_checked \"a_piece_of_code\"}"}
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    33
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    34
  The code is checked by sending the ML-expression @{text [quotes] "val _ =
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    35
  a_piece_of_code"} to the ML-compiler (i.e.~the function @{ML
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    36
  "ML_Context.eval_in"} in Line 4 below). The complete code of the
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    37
  document antiquotation is as follows:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    38
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
114
13fd0a83d3c3 properly handled linenumbers in ML-text and Isar-proofs
Christian Urban <urbanc@in.tum.de>
parents: 74
diff changeset
    41
ML%linenosgray{*fun ml_val code_txt = "val _ = " ^ code_txt
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    43
fun output_ml {context = ctxt, ...} code_txt =
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    44
  (ML_Context.eval_in (SOME ctxt) false Position.none (ml_val code_txt); 
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    45
   ThyOutput.output (map Pretty.str (space_explode "\n" code_txt)))
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
165
890fbfef6d6b partially adapted to new antiquotation infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 154
diff changeset
    47
val _ = ThyOutput.antiquotation "ML_checked" (Scan.lift Args.name) output_ml*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
text {*
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    50
  The parser @{ML "(Scan.lift Args.name)"} in line 9 parses a string, in this
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    51
  case the code. As mentioned before, the code is sent to the ML-compiler in
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    52
  the line 4 using the function @{ML ml_val}, which constructs the appropriate
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    53
  ML-expression.  If the code is ``approved'' by the compiler, then the output
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    54
  function @{ML "ThyOutput.output"} in the next line pretty prints the
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    55
  code. This function expects that the code is a list of (pretty)strings where
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    56
  each string correspond to a line in the output. Therefore the use of @{ML
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    57
  "(space_explode \"\\n\" txt)" for txt} which produces this list according to
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    58
  linebreaks.  There are a number of options for antiquotations that are
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    59
  observed by @{ML ThyOutput.output} when printing the code (including @{text
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    60
  "[display]"} and @{text "[quotes]"}). Line 7 sets up the new document
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    61
  antiquotation.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    62
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    63
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    64
  \begin{readmore}
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    65
  For more information about options of document antiquotations see \rsccite{sec:antiq}).
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    66
  \end{readmore}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    68
  Since we used the argument @{ML "Position.none"}, the compiler cannot give specific 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    69
  information about the line number, in case an error is detected. We 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    70
  can improve the code above slightly by writing 
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
171
18f90044c777 simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 168
diff changeset
    73
ML%linenosgray{*fun output_ml {context = ctxt, ...} (code_txt, pos) =
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    74
  (ML_Context.eval_in (SOME ctxt) false pos (ml_val code_txt);
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    75
   ThyOutput.output (map Pretty.str (space_explode "\n" code_txt)))
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
165
890fbfef6d6b partially adapted to new antiquotation infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 154
diff changeset
    77
val _ = ThyOutput.antiquotation "ML_checked"
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    78
         (Scan.lift (OuterParse.position Args.name)) output_ml *}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
text {*
171
18f90044c777 simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 168
diff changeset
    81
  where in Lines 1 and 2 the positional information is properly treated. The
18f90044c777 simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 168
diff changeset
    82
  parser @{ML OuterParse.position} encodes the positional information in the 
18f90044c777 simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 168
diff changeset
    83
  result.
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    84
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    85
  We can now write in a document @{text "@{ML_checked \"2 + 3\"}"} in order to
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    86
  obtain @{ML_checked "2 + 3"} and be sure that this code compiles until
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    87
  somebody changes the definition of \mbox{@{ML "(op +)"}}.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    88
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    89
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    90
  The second document antiquotation we describe extends the first by a pattern
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    91
  that specifies what the result of the ML-code should be and check the
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    92
  consistency of the actual result with the given pattern. For this we are
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    93
  going to implement the document antiquotation
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
    94
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    95
  
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    96
  @{text [display] "@{ML_resp \"a_piece_of_code\" \"a_pattern\"}"}
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    97
  
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    98
  To add some convenience and also to deal with large outputs, the user can
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
    99
  give a partial specification inside the pattern by giving abbreviations of
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   100
  the form @{text [quotes] "\<dots>"}. For example @{text "(\<dots>, \<dots>)"} for specifying a
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   101
  pair.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   102
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   103
  In the document antiquotation @{text "@{ML_checked \"piece_of_code\"}"}
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   104
  above we have sent the expression @{text [quotes] "val _ = piece_of_code"}
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   105
  to the compiler, now instead the wildcard @{text "_"} we will be replaced by
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   106
  the given pattern. To do this we need to replace in the input the @{text
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   107
  [quotes] "\<dots>"} by @{text [quotes] "_"} before sending the code to the
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   108
  compiler. The following function will do this:
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
   111
ML{*fun ml_pat (code_txt, pat) =
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   112
let val pat' = 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   113
         implode (map (fn "\<dots>" => "_" | s => s) (Symbol.explode pat))
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   114
in 
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   115
  "val " ^ pat' ^ " = " ^ code_txt 
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   116
end*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   118
text {* 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   119
  Next we like to add a response indicator to the result using:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   120
*}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   121
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   122
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   123
ML{*fun add_resp pat = map (fn s => "> " ^ s) pat*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   125
text {* 
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   126
  The rest of the code of the document antiquotation is
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   127
*}
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   128
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   129
ML{*fun output_ml_resp {context = ctxt, ...} ((code_txt, pat), pos) = 
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   130
  (ML_Context.eval_in (SOME ctxt) false pos (ml_pat (code_txt, pat));
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   131
   let 
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   132
     val output1 = space_explode "\n" code_txt 
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   133
     val output2 = add_resp (space_explode "\n" pat)
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   134
   in 
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   135
     ThyOutput.output (map Pretty.str (output1 @ output2)) 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   136
   end)
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
165
890fbfef6d6b partially adapted to new antiquotation infrastructure
Christian Urban <urbanc@in.tum.de>
parents: 154
diff changeset
   138
val _ = ThyOutput.antiquotation "ML_resp" 
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   139
         (Scan.lift (OuterParse.position (Args.name -- Args.name))) 
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   140
           output_ml_resp*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   142
text {*
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   143
  This extended document antiquotation allows us to write
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   144
 
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   145
  @{text [display] "@{ML_resp [display] \"true andalso false\" \"false\"}"}
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   146
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   147
  to obtain
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   149
  @{ML_resp [display] "true andalso false" "false"} 
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   151
  or 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   152
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   153
  @{text [display] "@{ML_resp [display] \"let val i = 3 in (i * i, \"foo\") end\" \"(9, \<dots>)\"}"}
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   154
  
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   155
  to obtain
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   156
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   157
  @{ML_resp [display] "let val i = 3 in (i * i, \"foo\") end" "(9, \<dots>)"} 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   158
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   159
  In both cases, the check by the compiler ensures that code and result
175
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   160
  match. A limitation of this document antiquotation, however, is that the
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   161
  pattern can only be given for values that can be constructed. This excludes
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   162
  values that are abstract datatypes, like @{ML_type thm}s and @{ML_type cterm}s.
7c09bd3227c5 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 171
diff changeset
   163
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   164
*}
168
009ca4807baa polished somewhat the recipes and solutions
Christian Urban <urbanc@in.tum.de>
parents: 165
diff changeset
   165
end