src/Doc/System/Scala.thy
author wenzelm
Sat, 13 Mar 2021 12:36:24 +0100
changeset 73419 22f3f2117ed7
parent 72759 bd5ee3148132
child 73987 fc363a3b690a
permissions -rw-r--r--
clarified signature: function_thread is determined in Isabelle/Scala, not Isabelle/ML;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61656
cfabbc083977 more uniform jEdit properties;
wenzelm
parents: 61575
diff changeset
     1
(*:maxLineLen=78:*)
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
     2
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
     3
theory Scala
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
     4
imports Base
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
     5
begin
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
     6
72252
3b17e7688dc6 updated documentation;
wenzelm
parents: 72197
diff changeset
     7
chapter \<open>Isabelle/Scala systems programming \label{sec:scala}\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
     8
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
     9
text \<open>
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    10
  Isabelle/ML and Isabelle/Scala are the two main implementation languages of
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    11
  the Isabelle environment:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    12
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    13
    \<^item> Isabelle/ML is for \<^emph>\<open>mathematics\<close>, to develop tools within the context
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    14
    of symbolic logic, e.g.\ for constructing proofs or defining
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    15
    domain-specific formal languages. See the \<^emph>\<open>Isabelle/Isar implementation
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    16
    manual\<close> @{cite "isabelle-implementation"} for more details.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    17
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    18
    \<^item> Isabelle/Scala is for \<^emph>\<open>physics\<close>, to connect with the world of systems
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    19
    and services, including editors and IDE frameworks.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    20
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    21
  There are various ways to access Isabelle/Scala modules and operations:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    22
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    23
    \<^item> Isabelle command-line tools (\secref{sec:scala-tools}) run in a separate
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    24
    Java process.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    25
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    26
    \<^item> Isabelle/ML antiquotations access Isabelle/Scala functions
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    27
    (\secref{sec:scala-functions}) via the PIDE protocol: execution happens
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    28
    within the running Java process underlying Isabelle/Scala.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    29
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    30
    \<^item> The \<^verbatim>\<open>Console/Scala\<close> plugin of Isabelle/jEdit @{cite "isabelle-jedit"}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    31
    operates on the running Java application, using the Scala
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    32
    read-eval-print-loop (REPL).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    33
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    34
  The main Isabelle/Scala functionality is provided by \<^verbatim>\<open>Pure.jar\<close>, but
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    35
  further add-ons are bundled with Isabelle, e.g.\ to access SQLite or
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    36
  PostgreSQL using JDBC (Java Database Connectivity).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    37
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    38
  Other components may augment the system environment by providing a suitable
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    39
  \<^path>\<open>etc/settings\<close> shell script in the component directory. Some shell
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    40
  functions are available to help with that:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    41
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    42
    \<^item> Function \<^bash_function>\<open>classpath\<close> adds \<^verbatim>\<open>jar\<close> files in Isabelle path
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    43
    notation (POSIX). On Windows, this is converted to native path names
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    44
    before invoking @{tool java} or @{tool scala} (\secref{sec:scala-tools}).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    45
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    46
    \<^item> Function \<^bash_function>\<open>isabelle_scala_service\<close> registers global
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    47
    service providers as subclasses of
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    48
    \<^scala_type>\<open>isabelle.Isabelle_System.Service\<close>, using the raw Java name
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    49
    according to @{scala_method (in java.lang.Object) getClass} (it should be
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    50
    enclosed in single quotes to avoid special characters like \<^verbatim>\<open>$\<close> to be
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    51
    interpreted by the shell).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    52
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    53
    Particular Isabelle/Scala services require particular subclasses:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    54
    instances are filtered according to their dynamic type. For example, class
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    55
    \<^scala_type>\<open>isabelle.Isabelle_Scala_Tools\<close> collects Scala command-line
72197
957bf00eff2a proper name (amending 742d94015918);
wenzelm
parents: 72103
diff changeset
    56
    tools, and class \<^scala_type>\<open>isabelle.Scala.Functions\<close>
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    57
    collects Scala functions (\secref{sec:scala-functions}).
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
    58
\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    59
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    60
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    61
section \<open>Command-line tools \label{sec:scala-tools}\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    62
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    63
subsection \<open>Java Runtime Environment \label{sec:tool-java}\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    64
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
    65
text \<open>
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
    66
  The @{tool_def java} tool is a direct wrapper for the Java Runtime
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
    67
  Environment, within the regular Isabelle settings environment
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    68
  (\secref{sec:settings}) and Isabelle classpath. The command line arguments
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    69
  are that of the bundled Java distribution: see option \<^verbatim>\<open>-help\<close> in
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    70
  particular.
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    71
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    72
  The \<^verbatim>\<open>java\<close> executable is taken from @{setting ISABELLE_JDK_HOME}, according
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    73
  to the standard directory layout for regular distributions of OpenJDK.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    74
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    75
  The shell function \<^bash_function>\<open>isabelle_jdk\<close> allows shell scripts to
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    76
  invoke other Java tools robustly (e.g.\ \<^verbatim>\<open>isabelle_jdk jar\<close>), without
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    77
  depending on accidental operating system installations.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58553
diff changeset
    78
\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    79
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    80
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    81
subsection \<open>Scala toplevel \label{sec:tool-scala}\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    82
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
    83
text \<open>
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    84
  The @{tool_def scala} tool is a direct wrapper for the Scala toplevel,
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    85
  similar to @{tool java} above. The command line arguments are that of the
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    86
  bundled Scala distribution: see option \<^verbatim>\<open>-help\<close> in particular. This allows
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    87
  to interact with Isabelle/Scala interactively.
71897
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    88
\<close>
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    89
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    90
subsubsection \<open>Example\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
    91
71897
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    92
text \<open>
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    93
  Explore the Isabelle system environment in Scala:
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    94
  @{verbatim [display, indent = 2] \<open>$ isabelle scala\<close>}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
    95
  @{scala [display, indent = 2]
71897
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    96
\<open>import isabelle._
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    97
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    98
val isabelle_home = Isabelle_System.getenv("ISABELLE_HOME")
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
    99
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
   100
val options = Options.init()
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
   101
options.bool("browser_info")
2cf0b0293f0d proper check of example;
wenzelm
parents: 71892
diff changeset
   102
options.string("document")\<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58553
diff changeset
   103
\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   104
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   105
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   106
subsection \<open>Scala compiler \label{sec:tool-scalac}\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   107
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   108
text \<open>
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   109
  The @{tool_def scalac} tool is a direct wrapper for the Scala compiler; see
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   110
  also @{tool scala} above. The command line arguments are that of the
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   111
  bundled Scala distribution.
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   112
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   113
  This allows to compile further Scala modules, depending on existing
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   114
  Isabelle/Scala functionality. The resulting \<^verbatim>\<open>class\<close> or \<^verbatim>\<open>jar\<close> files can be
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   115
  added to the Java classpath using the shell function
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   116
  \<^bash_function>\<open>classpath\<close>. Thus add-on components can register themselves
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   117
  in a modular manner, see also \secref{sec:components}.
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   118
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   119
  Note that Isabelle/jEdit @{cite "isabelle-jedit"} has its own mechanisms for
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   120
  adding plugin components. This needs special attention, since it overrides
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   121
  the standard Java class loader.
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   122
\<close>
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   123
52116
abf9fcfa65cf added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
wenzelm
parents: 48985
diff changeset
   124
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   125
subsection \<open>Scala script wrapper\<close>
52116
abf9fcfa65cf added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
wenzelm
parents: 48985
diff changeset
   126
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   127
text \<open>
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   128
  The executable @{executable "$ISABELLE_HOME/bin/isabelle_scala_script"}
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   129
  allows to run Isabelle/Scala source files stand-alone programs, by using a
62415
62c03eb38e49 isabelle_scala_script is usually found by PATH;
wenzelm
parents: 61656
diff changeset
   130
  suitable ``hash-bang'' line and executable file permissions. For example:
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   131
  @{verbatim [display, indent = 2] \<open>#!/usr/bin/env isabelle_scala_script\<close>}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   132
  @{scala [display, indent = 2]
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   133
\<open>val options = isabelle.Options.init()
52116
abf9fcfa65cf added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
wenzelm
parents: 48985
diff changeset
   134
Console.println("browser_info = " + options.bool("browser_info"))
61407
7ba7b8103565 @{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents: 58618
diff changeset
   135
Console.println("document = " + options.string("document"))\<close>}
52116
abf9fcfa65cf added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
wenzelm
parents: 48985
diff changeset
   136
62415
62c03eb38e49 isabelle_scala_script is usually found by PATH;
wenzelm
parents: 61656
diff changeset
   137
  This assumes that the executable may be found via the @{setting PATH} from
62c03eb38e49 isabelle_scala_script is usually found by PATH;
wenzelm
parents: 61656
diff changeset
   138
  the process environment: this is the case when Isabelle settings are active,
62c03eb38e49 isabelle_scala_script is usually found by PATH;
wenzelm
parents: 61656
diff changeset
   139
  e.g.\ in the context of the main Isabelle tool wrapper
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 62415
diff changeset
   140
  \secref{sec:isabelle-tool}. Alternatively, the full
6e1e8b5abbfa more symbols;
wenzelm
parents: 62415
diff changeset
   141
  \<^file>\<open>$ISABELLE_HOME/bin/isabelle_scala_script\<close> may be specified in expanded
62415
62c03eb38e49 isabelle_scala_script is usually found by PATH;
wenzelm
parents: 61656
diff changeset
   142
  form.
61575
f18f6e51e901 tuned whitespace;
wenzelm
parents: 61503
diff changeset
   143
\<close>
52116
abf9fcfa65cf added isabelle_scala_script wrapper -- NB: portable hash-bang allows exactly one executable, without additional arguments;
wenzelm
parents: 48985
diff changeset
   144
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   145
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   146
subsection \<open>Project setup for common Scala IDEs\<close>
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   147
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   148
text \<open>
71389
wenzelm
parents: 71378
diff changeset
   149
  The @{tool_def scala_project} tool creates a project configuration for
wenzelm
parents: 71378
diff changeset
   150
  Isabelle/Scala/jEdit:
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   151
  @{verbatim [display]
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   152
\<open>Usage: isabelle scala_project [OPTIONS] PROJECT_DIR
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   153
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   154
  Options are:
71503
df7494f14388 clarified command line;
wenzelm
parents: 71389
diff changeset
   155
    -L           make symlinks to original scala files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   156
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   157
  Setup Gradle project for Isabelle/Scala/jEdit --- to support Scala IDEs
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   158
  such as IntelliJ IDEA.\<close>}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   159
71389
wenzelm
parents: 71378
diff changeset
   160
  The generated configuration is for Gradle\<^footnote>\<open>\<^url>\<open>https://gradle.org\<close>\<close>, but the
wenzelm
parents: 71378
diff changeset
   161
  main purpose is to import it into common Scala IDEs, such as IntelliJ
wenzelm
parents: 71378
diff changeset
   162
  IDEA\<^footnote>\<open>\<^url>\<open>https://www.jetbrains.com/idea\<close>\<close>. This allows to explore the
wenzelm
parents: 71378
diff changeset
   163
  sources with static analysis and other hints in real-time.
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   164
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   165
  The specified project directory needs to be fresh. The generated files refer
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   166
  to physical file-system locations, using the path notation of the underlying
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   167
  OS platform. Thus the project needs to be recreated whenever the Isabelle
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   168
  installation is changed or moved.
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   169
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   170
  \<^medskip>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   171
  By default, Scala sources are \<^emph>\<open>copied\<close> from the Isabelle distribution and
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   172
  editing them within the IDE has no permanent effect.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   173
71523
abe3c309998b proper option;
wenzelm
parents: 71503
diff changeset
   174
  Option \<^verbatim>\<open>-L\<close> produces \<^emph>\<open>symlinks\<close> to the original files: this allows to
71389
wenzelm
parents: 71378
diff changeset
   175
  develop Isabelle/Scala/jEdit within an external Scala IDE. Note that
wenzelm
parents: 71378
diff changeset
   176
  building the result always requires \<^verbatim>\<open>isabelle jedit -b\<close> on the
wenzelm
parents: 71378
diff changeset
   177
  command-line.
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   178
\<close>
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents: 63680
diff changeset
   179
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   180
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   181
section \<open>Registered Isabelle/Scala functions \label{sec:scala-functions}\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   182
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   183
subsection \<open>Defining functions in Isabelle/Scala\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   184
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   185
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   186
  A Scala functions of type \<^scala_type>\<open>String => String\<close> may be wrapped as
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   187
  \<^scala_type>\<open>isabelle.Scala.Fun\<close> and collected via an instance of the
72197
957bf00eff2a proper name (amending 742d94015918);
wenzelm
parents: 72103
diff changeset
   188
  class \<^scala_type>\<open>isabelle.Scala.Functions\<close>. A system component
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   189
  can then register that class via \<^bash_function>\<open>isabelle_scala_service\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   190
  in \<^path>\<open>etc/settings\<close> (\secref{sec:components}). An example is the
72197
957bf00eff2a proper name (amending 742d94015918);
wenzelm
parents: 72103
diff changeset
   191
  predefined collection of \<^scala_type>\<open>isabelle.Scala.Functions\<close> in
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   192
  Isabelle/\<^verbatim>\<open>Pure.jar\<close> with the following line in
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   193
  \<^file>\<open>$ISABELLE_HOME/etc/settings\<close>:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   194
  @{verbatim [display, indent = 2] \<open>isabelle_scala_service 'isabelle.Functions'\<close>}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   195
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   196
  The overall list of registered functions is accessible in Isabelle/Scala as
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   197
  \<^scala_object>\<open>isabelle.Scala.functions\<close>.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   198
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   199
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   200
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   201
subsection \<open>Invoking functions in Isabelle/ML\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   202
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   203
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   204
  Isabelle/PIDE provides a protocol to invoke registered Scala functions in
72103
7b318273a4aa discontinued old batch-build functionality;
wenzelm
parents: 71907
diff changeset
   205
  ML: this works both within the Prover IDE and in batch builds.
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   206
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   207
  The subsequent ML antiquotations refer to Scala functions in a
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   208
  formally-checked manner.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   209
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   210
  \begin{matharray}{rcl}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   211
  @{ML_antiquotation_def "scala_function"} & : & \<open>ML_antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   212
  @{ML_antiquotation_def "scala"} & : & \<open>ML_antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   213
  \end{matharray}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   214
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   215
  \<^rail>\<open>
72332
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   216
    (@{ML_antiquotation scala_function} |
73419
22f3f2117ed7 clarified signature: function_thread is determined in Isabelle/Scala, not Isabelle/ML;
wenzelm
parents: 72759
diff changeset
   217
     @{ML_antiquotation scala}) @{syntax embedded}
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   218
  \<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   219
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   220
  \<^descr> \<open>@{scala_function name}\<close> inlines the checked function name as ML string
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   221
    literal.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   222
72332
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   223
  \<^descr> \<open>@{scala name}\<close> and \<open>@{scala_thread name}\<close> invoke the checked function via
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   224
  the PIDE protocol. In Isabelle/ML this appears as a function of type
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   225
  \<^ML_type>\<open>string -> string\<close>, which is subject to interrupts within the ML
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   226
  runtime environment as usual. A \<^scala>\<open>null\<close> result in Scala raises an
72332
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   227
  exception \<^ML>\<open>Scala.Null\<close> in ML. The execution of \<open>@{scala}\<close> works via a
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   228
  Scala future on a bounded thread farm, while \<open>@{scala_thread}\<close> always forks
319dd5c618a5 allow Scala function execution on separate thread: better reactivity, but potential overloading of the JVM;
wenzelm
parents: 72252
diff changeset
   229
  a separate Java thread.
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   230
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   231
  The standard approach of representing datatypes via strings works via XML in
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   232
  YXML transfer syntax. See Isabelle/ML operations and modules @{ML
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   233
  YXML.string_of_body}, @{ML YXML.parse_body}, @{ML_structure XML.Encode},
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   234
  @{ML_structure XML.Decode}; similarly for Isabelle/Scala. Isabelle symbols
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   235
  may have to be recoded via Scala operations
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   236
  \<^scala_method>\<open>isabelle.Symbol.decode\<close> and
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   237
  \<^scala_method>\<open>isabelle.Symbol.encode\<close>.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   238
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   239
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   240
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   241
subsubsection \<open>Examples\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   242
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   243
text \<open>
72759
bd5ee3148132 more antiquotations (reverting 4df341249348);
wenzelm
parents: 72332
diff changeset
   244
  Invoke the predefined Scala function \<^scala_function>\<open>echo\<close>:
71907
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   245
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   246
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   247
ML \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   248
  val s = "test";
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   249
  val s' = \<^scala>\<open>echo\<close> s;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   250
  \<^assert> (s = s')
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   251
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   252
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   253
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   254
  Let the Scala compiler process some toplevel declarations, producing a list
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   255
  of errors:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   256
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   257
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   258
ML \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   259
  val source = "class A(a: Int, b: Boolean)"
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   260
  val errors =
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   261
    \<^scala>\<open>scala_toplevel\<close> source
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   262
    |> YXML.parse_body
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   263
    |> let open XML.Decode in list string end;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   264
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   265
  \<^assert> (null errors)\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   266
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   267
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   268
  The above is merely for demonstration. See \<^ML>\<open>Scala_Compiler.toplevel\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   269
  for a more convenient version with builtin decoding and treatment of errors.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   270
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   271
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   272
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   273
section \<open>Documenting Isabelle/Scala entities\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   274
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   275
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   276
  The subsequent document antiquotations help to document Isabelle/Scala
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   277
  entities, with formal checking of names against the Isabelle classpath.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   278
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   279
  \begin{matharray}{rcl}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   280
  @{antiquotation_def "scala"} & : & \<open>antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   281
  @{antiquotation_def "scala_object"} & : & \<open>antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   282
  @{antiquotation_def "scala_type"} & : & \<open>antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   283
  @{antiquotation_def "scala_method"} & : & \<open>antiquotation\<close> \\
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   284
  \end{matharray}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   285
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   286
  \<^rail>\<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   287
    (@@{antiquotation scala} | @@{antiquotation scala_object})
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   288
      @{syntax embedded}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   289
    ;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   290
    @@{antiquotation scala_type} @{syntax embedded} types
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   291
    ;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   292
    @@{antiquotation scala_method} class @{syntax embedded} types args
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   293
    ;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   294
    class: ('(' @'in' @{syntax name} types ')')?
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   295
    ;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   296
    types: ('[' (@{syntax name} ',' +) ']')?
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   297
    ;
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   298
    args: ('(' (nat | (('_' | @{syntax name}) + ',')) ')')?
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   299
  \<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   300
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   301
  \<^descr> \<open>@{scala s}\<close> is similar to \<open>@{verbatim s}\<close>, but the given source text is
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   302
  checked by the Scala compiler as toplevel declaration (without evaluation).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   303
  This allows to write Isabelle/Scala examples that are statically checked.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   304
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   305
  \<^descr> \<open>@{scala_object x}\<close> checks the given Scala object name (simple value or
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   306
  ground module) and prints the result verbatim.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   307
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   308
  \<^descr> \<open>@{scala_type T[A]}\<close> checks the given Scala type name (with optional type
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   309
  parameters) and prints the result verbatim.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   310
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   311
  \<^descr> \<open>@{scala_method (in c[A]) m[B](n)}\<close> checks the given Scala method \<open>m\<close> in
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   312
  the context of class \<open>c\<close>. The method argument slots are either specified by
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   313
  a number \<open>n\<close> or by a list of (optional) argument types; this may refer to
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   314
  type variables specified for the class or method: \<open>A\<close> or \<open>B\<close> above.
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   315
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   316
  Everything except for the method name \<open>m\<close> is optional. The absence of the
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   317
  class context means that this is a static method. The absence of arguments
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   318
  with types means that the method can be determined uniquely as \<^verbatim>\<open>(\<close>\<open>m\<close>\<^verbatim>\<open> _)\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   319
  in Scala (no overloading).
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   320
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   321
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   322
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   323
subsubsection \<open>Examples\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   324
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   325
text \<open>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   326
  Miscellaneous Isabelle/Scala entities:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   327
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   328
    \<^item> object: \<^scala_object>\<open>isabelle.Isabelle_Process\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   329
    \<^item> type without parameter: @{scala_type isabelle.Console_Progress}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   330
    \<^item> type with parameter: @{scala_type List[A]}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   331
    \<^item> static method: \<^scala_method>\<open>isabelle.Isabelle_System.bash\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   332
    \<^item> class and method with type parameters:
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   333
      @{scala_method (in List[A]) map[B]("A => B")}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   334
    \<^item> overloaded method with argument type: @{scala_method (in Int) "+" (Int)}
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   335
\<close>
64c9628b39fc more documentation on Isabelle/Scala;
wenzelm
parents: 71897
diff changeset
   336
47825
4f25960417ae some coverage of Isabelle/Scala tools;
wenzelm
parents:
diff changeset
   337
end