Wrattler is a polyglot notebook system. It constructs dependency graph
and manages evaluation of nodes in the graph in the web browser, although
languages like R and Python that cannot run in the web browser delegate much
of the work to a server-side execution runtime.
When extending Wrattler, you have a range of options from creating (just) a
new server-side execution runtime to implementing custom user interface for
a cell. The types in this module let you imlement new language plugins that
do some interesting work directly in the web browser.
LanguagePlugin is the main
type that you need to implement if you want to add new language to Wrattler.
The type is responsible for parsing, binding (i.e. the construction of a
dependnecy graph), evaluation and also user interface.
Block is produced by parsing source
code. Each language can define its own type and store either the code itself
or some parsed abstract syntax tree.
Constructing dependency graph
The following types are related to the bind operation of a LanguagePlugin:
BindingContext provides
the language plugin with a cache for reusing past graph nodes, variables
that are in scope from previous cells (the ScopeDictionary
type) and also source files (e.g. *.py) that were imported in previous cells
(the Resource type).
BindingResult is the result of
bind. It includes one graph node representing the whole code cell and an
array representing exported data frames. It can also return new source files that
should be automatically loaded in further cells (as values of the
Resource type).
Evaluating graph node values
The following types are related to the eval operation of a LanguagePlugin:
EvaluationContext provides
the evaluator with files that are imported in previous cells.
The following types are needed when implementing custom editor for a new language:
Editor is the main type to implement.
Editors in Wrattler follow the Elm architecture. They expose render function, which
generates virtual HTML nodes based on the current state and update function, which
is used to update the state when an event happens.
Editor for each language has its own type of events. The type used to represent
state needs to implement the EditorState
interface.
BlockState is passed to render when rendering a notebook. It
stores the EditorState of the given
editor and information about dependency graph nodes corresponding to the cell.
EditorContext is passed as an extra
parameter to render. It provides operations for triggering events (to be called from
JavaScript event handlers), rebinding and triggering evaluation.
Wrattler is a polyglot notebook system. It constructs dependency graph and manages evaluation of nodes in the graph in the web browser, although languages like R and Python that cannot run in the web browser delegate much of the work to a server-side execution runtime.
When extending Wrattler, you have a range of options from creating (just) a new server-side execution runtime to implementing custom user interface for a cell. The types in this module let you imlement new language plugins that do some interesting work directly in the web browser.
LanguagePlugin
is the main type that you need to implement if you want to add new language to Wrattler. The type is responsible for parsing, binding (i.e. the construction of a dependnecy graph), evaluation and also user interface.Block
is produced by parsing source code. Each language can define its own type and store either the code itself or some parsed abstract syntax tree.Constructing dependency graph
The following types are related to the
bind
operation of aLanguagePlugin
:BindingContext
provides the language plugin with a cache for reusing past graph nodes, variables that are in scope from previous cells (theScopeDictionary
type) and also source files (e.g.*.py
) that were imported in previous cells (theResource
type).BindingResult
is the result ofbind
. It includes one graph node representing the whole code cell and an array representing exported data frames. It can also return new source files that should be automatically loaded in further cells (as values of theResource
type).Evaluating graph node values
The following types are related to the
eval
operation of aLanguagePlugin
:EvaluationContext
provides the evaluator with files that are imported in previous cells.EvaluationResult
represents the result of evaluation. This can be eitherEvaluationFailure
, consisting of an array of errors, orEvaluationSuccess
consisting of aValue
that should be stored with the graph node.Implementing custom editors
The following types are needed when implementing custom editor for a new language:
Editor
is the main type to implement. Editors in Wrattler follow the Elm architecture. They exposerender
function, which generates virtual HTML nodes based on the current state andupdate
function, which is used to update the state when an event happens.Editor for each language has its own type of events. The type used to represent state needs to implement the
EditorState
interface.BlockState
is passed torender
when rendering a notebook. It stores theEditorState
of the given editor and information about dependency graph nodes corresponding to the cell.EditorContext
is passed as an extra parameter torender
. It provides operations for triggering events (to be called from JavaScript event handlers), rebinding and triggering evaluation.