equal
deleted
inserted
replaced
159 which states that the given theorems should be considered as code |
159 which states that the given theorems should be considered as code |
160 equations for a @{text fun} statement -- the corresponding constant |
160 equations for a @{text fun} statement -- the corresponding constant |
161 is determined syntactically. The resulting code: |
161 is determined syntactically. The resulting code: |
162 *} |
162 *} |
163 |
163 |
164 text %quote {* |
164 text %quote %typewriter {* |
165 \begin{typewriter} |
165 @{code_stmts dequeue (consts) dequeue (Haskell)} |
166 @{code_stmts dequeue (consts) dequeue (Haskell)} |
|
167 \end{typewriter} |
|
168 *} |
166 *} |
169 |
167 |
170 text {* |
168 text {* |
171 \noindent You may note that the equality test @{term "xs = []"} has |
169 \noindent You may note that the equality test @{term "xs = []"} has |
172 been replaced by the predicate @{term "List.null xs"}. This is due |
170 been replaced by the predicate @{term "List.null xs"}. This is due |
217 \noindent During preprocessing, the membership test is rewritten, |
215 \noindent During preprocessing, the membership test is rewritten, |
218 resulting in @{const List.member}, which itself performs an explicit |
216 resulting in @{const List.member}, which itself performs an explicit |
219 equality check, as can be seen in the corresponding @{text SML} code: |
217 equality check, as can be seen in the corresponding @{text SML} code: |
220 *} |
218 *} |
221 |
219 |
222 text %quote {* |
220 text %quote %typewriter {* |
223 \begin{typewriter} |
221 @{code_stmts collect_duplicates (SML)} |
224 @{code_stmts collect_duplicates (SML)} |
|
225 \end{typewriter} |
|
226 *} |
222 *} |
227 |
223 |
228 text {* |
224 text {* |
229 \noindent Obviously, polymorphic equality is implemented the Haskell |
225 \noindent Obviously, polymorphic equality is implemented the Haskell |
230 way using a type class. How is this achieved? HOL introduces an |
226 way using a type class. How is this achieved? HOL introduces an |
257 text {* |
253 text {* |
258 \noindent In the corresponding code, there is no equation |
254 \noindent In the corresponding code, there is no equation |
259 for the pattern @{term "AQueue [] []"}: |
255 for the pattern @{term "AQueue [] []"}: |
260 *} |
256 *} |
261 |
257 |
262 text %quote {* |
258 text %quote %typewriter {* |
263 \begin{typewriter} |
259 @{code_stmts strict_dequeue (consts) strict_dequeue (Haskell)} |
264 @{code_stmts strict_dequeue (consts) strict_dequeue (Haskell)} |
|
265 \end{typewriter} |
|
266 *} |
260 *} |
267 |
261 |
268 text {* |
262 text {* |
269 \noindent In some cases it is desirable to have this |
263 \noindent In some cases it is desirable to have this |
270 pseudo-\qt{partiality} more explicitly, e.g.~as follows: |
264 pseudo-\qt{partiality} more explicitly, e.g.~as follows: |
300 text {* |
294 text {* |
301 \noindent Then the code generator will just insert an error or |
295 \noindent Then the code generator will just insert an error or |
302 exception at the appropriate position: |
296 exception at the appropriate position: |
303 *} |
297 *} |
304 |
298 |
305 text %quote {* |
299 text %quote %typewriter {* |
306 \begin{typewriter} |
300 @{code_stmts strict_dequeue' (consts) empty_queue strict_dequeue' (Haskell)} |
307 @{code_stmts strict_dequeue' (consts) empty_queue strict_dequeue' (Haskell)} |
|
308 \end{typewriter} |
|
309 *} |
301 *} |
310 |
302 |
311 text {* |
303 text {* |
312 \noindent This feature however is rarely needed in practice. Note |
304 \noindent This feature however is rarely needed in practice. Note |
313 also that the HOL default setup already declares @{const undefined} |
305 also that the HOL default setup already declares @{const undefined} |