diff -r d15dde801536 -r 7cffe366d333 src/Doc/Codegen/Further.thy --- a/src/Doc/Codegen/Further.thy Tue Jun 14 15:54:28 2016 +0100 +++ b/src/Doc/Codegen/Further.thy Tue Jun 14 20:48:41 2016 +0200 @@ -39,71 +39,8 @@ the type arguments are just appended. Otherwise they are ignored; hence user-defined adaptations for polymorphic constants have to be designed very carefully to avoid ambiguity. - - Isabelle's type classes are mapped onto @{text Scala} implicits; in - cases with diamonds in the subclass hierarchy this can lead to - ambiguities in the generated code: -\ - -class %quote class1 = - fixes foo :: "'a \ 'a" - -class %quote class2 = class1 - -class %quote class3 = class1 - -text \ - \noindent Here both @{class class2} and @{class class3} inherit from @{class class1}, - forming the upper part of a diamond. -\ - -definition %quote bar :: "'a :: {class2, class3} \ 'a" where - "bar = foo" - -text \ - \noindent This yields the following code: -\ - -text %quotetypewriter \ - @{code_stmts bar (Scala)} \ -text \ - \noindent This code is rejected by the @{text Scala} compiler: in - the definition of @{text bar}, it is not clear from where to derive - the implicit argument for @{text foo}. - - The solution to the problem is to close the diamond by a further - class with inherits from both @{class class2} and @{class class3}: -\ - -class %quote class4 = class2 + class3 - -text \ - \noindent Then the offending code equation can be restricted to - @{class class4}: -\ - -lemma %quote [code]: - "(bar :: 'a::class4 \ 'a) = foo" - by (simp only: bar_def) - -text \ - \noindent with the following code: -\ - -text %quotetypewriter \ - @{code_stmts bar (Scala)} -\ - -text \ - \noindent which exposes no ambiguity. - - Since the preprocessor (cf.~\secref{sec:preproc}) propagates sort - constraints through a system of code equations, it is usually not - very difficult to identify the set of code equations which actually - needs more restricted sort constraints. -\ subsection \Modules namespace\