CookBook/Recipes/Antiquotes.thy
author Christian Urban <urbanc@in.tum.de>
Tue, 16 Dec 2008 17:28:05 +0000 (2008-12-16)
changeset 58 f3794c231898
parent 53 0c3580c831a4
child 59 b5914f3c643c
permissions -rw-r--r--
fixed typos
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 {*
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    10
  {\bf Problem:} 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    11
  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
    12
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    13
  {\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
    14
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    15
  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
    16
  various entities in a document. They can also be used for sophisticated
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    17
  \LaTeX-hacking.
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    19
  Below we give the code for two antiquotations that can be used to typeset
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    20
  ML-code and also to check whether the given code actually compiles. This
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    21
  provides a sanity check for the code and also allows one to keep documents
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    22
  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
    23
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    24
  We first describe the antiquotation @{text "@{ML_checked \"expr\"}"}. This
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    25
  antiquotation takes a piece of code as argument. The argument is checked
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    26
  by sending the ML-expression @{text [quotes] "val _ = \<dots>"} containing the
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    27
  given argument to the ML-compiler (i.e.~the function @{ML "ML_Context.eval_in"}
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    28
  in Line 4 in the code below). The code of @{text "@{ML_checked \"expr\"}"} 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    29
  is as follows:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    30
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    33
ML %linenumbers {*fun ml_val txt = "val _ = " ^ txt
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
fun output_ml ml src ctxt txt =
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    36
  (ML_Context.eval_in (SOME ctxt) false Position.none (ml txt); 
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    37
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    38
                                            (space_explode "\n" txt))
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
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
 [("ML_checked", ThyOutput.args (Scan.lift Args.name) (output_ml ml_val))]
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
text {*
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    45
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    46
  Note that the parser @{ML "(Scan.lift Args.name)"} in line 9 parses a string, 
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    47
  in this case the code given as argument. This argument is send to the ML-compiler in the line 4.  
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    48
  If the code is ``approved'' by the compiler, then the output function @{ML
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    49
  "ThyOutput.output_list (fn _ => fn s => Pretty.str s)"} in the next line pretty prints the
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    50
  code. This function expects that the code is a list of strings where each
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    51
  string correspond to a line. Therefore the @{ML "(space_explode \"\\n\" txt)" for txt} 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    52
  which produces this list.  There are a number of options for antiquotations
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    53
  that are observed by @{ML ThyOutput.output_list} when printing the code (for
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    54
  example @{text "[display]"}, @{text "[quotes]"} and @{text "[source]"}).
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    55
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    56
  \begin{readmore}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    57
  For more information about options of antiquotations see \rsccite{sec:antiq}).
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    58
  \end{readmore}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    60
  Since we used the argument @{ML "Position.none"}, the compiler cannot give specific 
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  information about the line number where an error might have occurred. We 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  can improve this code slightly by writing 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    66
ML %linenumbers {* fun output_ml ml src ctxt (txt,pos) =
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
  (ML_Context.eval_in (SOME ctxt) false pos (ml txt);
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    68
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    69
                                            (space_explode "\n" txt))
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
 [("ML_checked", ThyOutput.args 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
       (Scan.lift (OuterParse.position Args.name)) (output_ml ml_val))]
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
text {*
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    77
  where in Lines 1 and 2 the positional information is properly treated.
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    78
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  (FIXME: say something about OuterParse.position)
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    80
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    81
  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
    82
  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
    83
  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
    84
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    85
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    86
  The second antiquotation extends the first by allowing also to give
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    87
  hints what the result of the ML-code is and check the consistency of 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    88
  the actual result with these hints. For this we use the antiquotation  
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    89
  @{text "@{ML_response \"expr\" \"pat\"}"}
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    90
  whose first argument is the ML-code and the second is a pattern specifying
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    91
  the result. To add some convenience we allow the user to give a partial
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    92
  specification using @{text "\<dots>"}.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    93
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    94
  In the antiquotation @{text "@{ML_checked \"expr\"}"} we send the expression 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    95
  @{text [quotes] "val _ = expr"} to the compiler. Instead of the wildcard
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    96
  @{text "_"}, we will here use the hints to construct a proper pattern. To
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    97
  do this we need to replace the @{text "\<dots>"} by @{text "_"} before sending the 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    98
  code to the compiler. The function 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    99
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
   102
ML {* 
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
fun ml_pat (rhs, pat) =
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   104
let val pat' = implode (map (fn "\<dots>" => "_" | s => s) (Symbol.explode pat))
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   105
in "val " ^ pat' ^ " = " ^ rhs end;
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   106
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   108
text {* 
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
   109
  will construct the pattern that the compiler can use. Next we like to add 
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
   110
  a response indicator to the result using:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   111
*}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   112
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   113
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   114
ML {*
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
fun add_response_indicator txt =
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
  map (fn s => "> " ^ s) (space_explode "\n" txt)
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   117
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   119
text {* 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   120
  The rest of the code of the antiquotation is
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
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   123
ML {*
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
fun output_ml_response ml src ctxt ((lhs,pat),pos) = 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  (ML_Context.eval_in (SOME ctxt) false pos (ml (lhs,pat));
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  let val txt = (space_explode "\n" lhs) @ (add_response_indicator pat)
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  in ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt txt end)
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
 [("ML_response", 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   131
     ThyOutput.args 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   132
      (Scan.lift (OuterParse.position (Args.name -- Args.name))) 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   133
      (output_ml_response ml_pat))]
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   136
text {*
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   137
  This extended antiquotation allows us to write 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   138
  @{text [display] "@{ML_response [display] \"true andalso false\" \"false\"}"}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   139
  to obtain
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
@{ML_response [display] "true andalso false" "false"} 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   143
  or 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   144
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   145
@{text [display] "@{ML_response [display] \"let val i = 3 in (i * i,\"foo\") end\" \"(9,\<dots>)\"}"}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   146
  
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   147
  to obtain
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   148
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   149
@{ML_response [display] "let val i = 3 in (i * i,\"foo\") end" "(9,\<dots>)"} 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   150
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   151
  In both cases, the check by the compiler ensures that code and result match. A limitation
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   152
  of this antiquotation is that the hints can only be given for results that can actually
53
0c3580c831a4 removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents: 51
diff changeset
   153
  be constructed as a pattern. This excludes values that are abstract datatypes, like 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   154
  theorems or cterms.
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   155
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   156
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
end
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
  
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163