CookBook/Recipes/Antiquotes.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 17 Dec 2008 05:08:33 +0000
changeset 59 b5914f3c643c
parent 58 f3794c231898
child 65 c8e9a4f97916
permissions -rw-r--r--
tuned
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
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    25
  antiquotation takes a piece of code as argument. The code 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"}
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    28
  in Line 4 below). The complete code of the antiquotation is as follows:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    29
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    32
ML %linenumbers {*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
    33
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    34
fun output_ml src ctxt code_txt =
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    35
  (ML_Context.eval_in (SOME ctxt) false Position.none (ml_val code_txt); 
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    36
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    37
                                            (space_explode "\n" code_txt))
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
val _ = ThyOutput.add_commands
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    40
 [("ML_checked", ThyOutput.args (Scan.lift Args.name) output_ml)]
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
*}
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
text {*
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    44
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    45
  Note that the parser @{ML "(Scan.lift Args.name)"} in line 9 parses a string, 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    46
  in this case the code given as argument. As mentioned before, this argument 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    47
  is send to the ML-compiler in the line 4 using the function @{ML ml_val},
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    48
  which constructs an apropriate ML-expression.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    49
  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
    50
  "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
    51
  code. This function expects that the code is a list of strings where each
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    52
  string correspond to a line in the output. Therefore the use of 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    53
  @{ML "(space_explode \"\\n\" txt)" for txt} 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    54
  which produces this list according to linebreaks.  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
    55
  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
    56
  example @{text "[display]"}, @{text "[quotes]"} and @{text "[source]"}).
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    57
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    58
  \begin{readmore}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    59
  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
    60
  \end{readmore}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    62
  Since we used the argument @{ML "Position.none"}, the compiler cannot give specific 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    63
  information about the line number, in case an error is detected. We 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    64
  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
    65
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    68
ML %linenumbers {* fun output_ml src ctxt (code_txt,pos) =
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    69
  (ML_Context.eval_in (SOME ctxt) false pos (ml_val code_txt);
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    70
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    71
                                            (space_explode "\n" code_txt))
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
 [("ML_checked", ThyOutput.args 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    75
       (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
    76
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
text {*
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    79
  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
    80
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  (FIXME: say something about OuterParse.position)
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    82
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    83
  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
    84
  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
    85
  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
    86
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    87
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    88
  The second antiquotation extends the first by allowing also to give
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    89
  hints what the result of the ML-code should be and to check the consistency of 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    90
  the actual result with these hints. For this we are going to implement the 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    91
  antiquotation  
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    92
  @{text "@{ML_response \"expr\" \"pat\"}"}
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    93
  whose first argument is the ML-code and the second is a pattern specifying
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    94
  the result. To add some convenience and allow dealing with large outputs,
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    95
  the user can give a partial specification including abbreviations 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    96
  @{text [quotes] "\<dots>"}.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    97
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    98
  Whereas in the antiquotation @{text "@{ML_checked \"expr\"}"} above, we have
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    99
  sent the expression 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   100
  @{text [quotes] "val _ = expr"} to the compiler, in this antiquotation the wildcard
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   101
  @{text "_"} we will be replaced by a proper pattern constructed the hints. To
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   102
  do this we need to replace the @{text [quotes] "\<dots>"} by @{text [quotes] "_"} 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   103
  before sending the code to the compiler. The following function will do this:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   104
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
   107
ML {* 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   108
fun ml_pat (code_txt, pat) =
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   109
   let val pat' = 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   110
         implode (map (fn "\<dots>" => "_" | s => s) (Symbol.explode pat))
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   111
   in 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   112
     "val " ^ pat' ^ " = " ^ code_txt 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   113
   end
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   114
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   116
text {* 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   117
  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
   118
*}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   119
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
ML {*
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   122
fun add_response_indicator pat =
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   123
  map (fn s => "> " ^ s) (space_explode "\n" pat)
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   124
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   126
text {* 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   127
  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
   128
  *}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   129
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   130
ML {*
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   131
fun output_ml_response src ctxt ((code_txt,pat),pos) = 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   132
  (ML_Context.eval_in (SOME ctxt) false pos (ml_pat (code_txt,pat));
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   133
   let 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   134
     val output = (space_explode "\n" code_txt) @ (add_response_indicator pat)
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   135
   in 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   136
     ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt output 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   137
   end)
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
 [("ML_response", 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   141
     ThyOutput.args 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   142
      (Scan.lift (OuterParse.position (Args.name -- Args.name))) 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   143
        output_ml_response)]
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   146
text {*
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   147
  This extended antiquotation allows us to write 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   148
  @{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
   149
  to obtain
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
@{ML_response [display] "true andalso false" "false"} 
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   153
  or 
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
@{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
   156
  
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   157
  to obtain
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   158
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   159
@{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
   160
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   161
  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
   162
  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
   163
  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
   164
  theorems or cterms.
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   165
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   166
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
end
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
  
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173