equal
deleted
inserted
replaced
58 Code_Evaluation.term_of TYPEREP('a) x (Code_Evaluation.Const (STR '''') (TYPEREP(unit)))" |
58 Code_Evaluation.term_of TYPEREP('a) x (Code_Evaluation.Const (STR '''') (TYPEREP(unit)))" |
59 for x :: "'a :: {typerep, term_of} lazy" |
59 for x :: "'a :: {typerep, term_of} lazy" |
60 by (rule term_of_anything) |
60 by (rule term_of_anything) |
61 |
61 |
62 text \<open> |
62 text \<open> |
63 The implementations of @{typ "_ lazy"} using language primitives cache forced values. |
63 The implementations of \<^typ>\<open>_ lazy\<close> using language primitives cache forced values. |
64 |
64 |
65 Term reconstruction for lazy looks into the lazy value and reconstructs it to the depth it has been evaluated. |
65 Term reconstruction for lazy looks into the lazy value and reconstructs it to the depth it has been evaluated. |
66 This is not done for Haskell as we do not know of any portable way to inspect whether a lazy value |
66 This is not done for Haskell as we do not know of any portable way to inspect whether a lazy value |
67 has been evaluated to or not. |
67 has been evaluated to or not. |
68 \<close> |
68 \<close> |
117 | constant termify_lazy \<rightharpoonup> (SML) "Lazy.termify'_lazy" |
117 | constant termify_lazy \<rightharpoonup> (SML) "Lazy.termify'_lazy" |
118 |
118 |
119 code_reserved SML Lazy |
119 code_reserved SML Lazy |
120 |
120 |
121 code_printing \<comment> \<open>For code generation within the Isabelle environment, we reuse the thread-safe |
121 code_printing \<comment> \<open>For code generation within the Isabelle environment, we reuse the thread-safe |
122 implementation of lazy from @{file "~~/src/Pure/Concurrent/lazy.ML"}\<close> |
122 implementation of lazy from \<^file>\<open>~~/src/Pure/Concurrent/lazy.ML\<close>\<close> |
123 code_module Lazy \<rightharpoonup> (Eval) \<open>\<close> for constant undefined |
123 code_module Lazy \<rightharpoonup> (Eval) \<open>\<close> for constant undefined |
124 | type_constructor lazy \<rightharpoonup> (Eval) "_ Lazy.lazy" |
124 | type_constructor lazy \<rightharpoonup> (Eval) "_ Lazy.lazy" |
125 | constant delay \<rightharpoonup> (Eval) "Lazy.lazy" |
125 | constant delay \<rightharpoonup> (Eval) "Lazy.lazy" |
126 | constant force \<rightharpoonup> (Eval) "Lazy.force" |
126 | constant force \<rightharpoonup> (Eval) "Lazy.force" |
127 | code_module Termify_Lazy \<rightharpoonup> (Eval) |
127 | code_module Termify_Lazy \<rightharpoonup> (Eval) |
218 | constant force \<rightharpoonup> (Scala) "Lazy.force" |
218 | constant force \<rightharpoonup> (Scala) "Lazy.force" |
219 | constant termify_lazy \<rightharpoonup> (Scala) "Lazy.termify'_lazy" |
219 | constant termify_lazy \<rightharpoonup> (Scala) "Lazy.termify'_lazy" |
220 |
220 |
221 code_reserved Scala Lazy |
221 code_reserved Scala Lazy |
222 |
222 |
223 text \<open>Make evaluation with the simplifier respect @{term delay}s.\<close> |
223 text \<open>Make evaluation with the simplifier respect \<^term>\<open>delay\<close>s.\<close> |
224 |
224 |
225 lemma delay_lazy_cong: "delay f = delay f" by simp |
225 lemma delay_lazy_cong: "delay f = delay f" by simp |
226 setup \<open>Code_Simp.map_ss (Simplifier.add_cong @{thm delay_lazy_cong})\<close> |
226 setup \<open>Code_Simp.map_ss (Simplifier.add_cong @{thm delay_lazy_cong})\<close> |
227 |
227 |
228 subsection \<open>Implementation\<close> |
228 subsection \<open>Implementation\<close> |