CookBook/Recipes/Antiquotes.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 16 Jan 2009 14:57:36 +0000
changeset 74 f6f8f8ba1eb1
parent 72 7b8c4fe235aa
child 114 13fd0a83d3c3
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
65
c8e9a4f97916 tuned and added a section about creating keyword files
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    17
  \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
    18
  obtain a list of all currently available document antiquotations and their options.
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
65
c8e9a4f97916 tuned and added a section about creating keyword files
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    20
  Below we give the code for two additional antiquotations that can be used to typeset
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    21
  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
    22
  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
    23
  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
    24
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    25
  We first describe the antiquotation @{text "ML_checked"} with the syntax:
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    26
 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    27
  @{text [display] "@{ML_checked \"a_piece_of_code\"}"}
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    28
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    29
  The code is checked by sending the ML-expression @{text [quotes] "val _ =
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    30
  a_piece_of_code"} to the ML-compiler (i.e.~the function @{ML
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    31
  "ML_Context.eval_in"} in Line 4 below). The complete code of the
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    32
  antiquotation is as follows:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    33
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
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
    36
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
    37
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    38
fun output_ml src ctxt code_txt =
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    39
  (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
    40
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    41
                                            (space_explode "\n" code_txt))
46
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
val _ = ThyOutput.add_commands
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
    44
 [("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
    45
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
text {*
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    47
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    48
  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
    49
  in this case the code given as argument. As mentioned before, this argument 
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    50
  is sent to the ML-compiler in the line 4 using the function @{ML ml_val},
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    51
  which constructs the appropriate ML-expression.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    52
  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
    53
  "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
    54
  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
    55
  string correspond to a line in the output. Therefore the use of 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    56
  @{ML "(space_explode \"\\n\" txt)" for txt} 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    57
  which produces this list according to linebreaks.  There are a number of options for antiquotations
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    58
  that are observed by @{ML ThyOutput.output_list} when printing the code (including
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    59
  @{text "[display]"}, @{text "[quotes]"} and @{text "[source]"}).
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    60
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    61
  \begin{readmore}
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    62
  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
    63
  \end{readmore}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
47
4daf913fdbe1 hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
    65
  Since we used the argument @{ML "Position.none"}, the compiler cannot give specific 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    66
  information about the line number, in case an error is detected. We 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    67
  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
    68
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
    70
ML%linenumbers{*fun output_ml src ctxt (code_txt,pos) =
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    71
  (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
    72
  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
    73
                                            (space_explode "\n" code_txt))
46
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
val _ = ThyOutput.add_commands
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
 [("ML_checked", ThyOutput.args 
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
    77
       (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
    78
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
text {*
58
f3794c231898 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 53
diff changeset
    80
  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
    81
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
  (FIXME: say something about OuterParse.position)
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    83
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    84
  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
    85
  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
    86
  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
    87
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    88
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    89
  The second antiquotation we describe extends the first by allowing also to give
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    90
  a pattern that specifies what the result of the ML-code should be and to check 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    91
  the consistency of the actual result with the given pattern. For this we are going 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    92
  to implement the antiquotation  
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    93
  
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    94
  @{text [display] "@{ML_resp \"a_piece_of_code\" \"pattern\"}"}
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    95
  
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    96
  To add some convenience and also to deal with large outputs,
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    97
  the user can give a partial specification by giving the abbreviation 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
    98
  @{text [quotes] "\<dots>"}. For example @{text "(\<dots>,\<dots>)"} for a pair.
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
    99
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   100
  Whereas in the antiquotation @{text "@{ML_checked \"piece_of_code\"}"} above, 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   101
  we have sent the expression 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   102
  @{text [quotes] "val _ = piece_of_code"} to the compiler, in the second the 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   103
  wildcard @{text "_"} we will be replaced by a proper pattern. To do this we 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   104
  need to replace the @{text [quotes] "\<dots>"} by 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   105
  @{text [quotes] "_"}  before sending the code to the compiler. The following 
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   106
  function will do this:
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   107
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
*}
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
   110
ML{*fun ml_pat (code_txt, pat) =
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   111
   let val pat' = 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   112
         implode (map (fn "\<dots>" => "_" | s => s) (Symbol.explode pat))
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   113
   in 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   114
     "val " ^ pat' ^ " = " ^ code_txt 
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
   115
   end*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   117
text {* 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   118
  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
   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
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   122
ML{*fun add_resp_indicator pat =
69
19106a9975c1 highligted the background of ML-code
Christian Urban <urbanc@in.tum.de>
parents: 65
diff changeset
   123
  map (fn s => "> " ^ s) (space_explode "\n" 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 {* 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   126
  The rest of the code of the 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
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   129
ML{*fun output_ml_resp src ctxt ((code_txt,pat),pos) = 
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   130
  (ML_Context.eval_in (SOME ctxt) false pos (ml_pat (code_txt,pat));
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   131
   let 
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   132
     val output = (space_explode "\n" code_txt) @ (add_resp_indicator pat)
59
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   133
   in 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   134
     ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt output 
Christian Urban <urbanc@in.tum.de>
parents: 58
diff changeset
   135
   end)
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
val _ = ThyOutput.add_commands
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   138
 [("ML_resp", 
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   139
     ThyOutput.args 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   140
      (Scan.lift (OuterParse.position (Args.name -- Args.name))) 
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   141
        output_ml_resp)]*}
46
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
text {*
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   144
  This extended antiquotation allows us to write
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   145
 
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   146
  @{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
   147
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   148
  to obtain
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   150
  @{ML_resp [display] "true andalso false" "false"} 
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
51
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   152
  or 
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   153
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   154
  @{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
   155
  
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   156
  to obtain
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   157
72
7b8c4fe235aa added an antiquotation option [gray] for gray boxes around displays
Christian Urban <urbanc@in.tum.de>
parents: 69
diff changeset
   158
  @{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
   159
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   160
  In both cases, the check by the compiler ensures that code and result match. A limitation
74
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   161
  of this antiquotation, however, is that the hints can only be given in case
Christian Urban <urbanc@in.tum.de>
parents: 72
diff changeset
   162
  they can 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
   163
  theorems or cterms.
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   164
c346c156a7cd completes the recipie on antiquotations
Christian Urban <urbanc@in.tum.de>
parents: 47
diff changeset
   165
*}
46
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
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
end
81e2d73f7191 added a section about document antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
  
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