This is a pure-Perl 6 implementation of a Perl 6 kernel for Jupyter notebooks.
Jupyter notebooks provide a web-based (or console-based) REPL for running code and serializing input and output.
You'll need to install zmq. Note that currently, version 4.1 is recommended by Net::ZMQ (though 4.2 is installed by, e.g. homebrew). If you run into stability issues, you may need to downgrade.
brew install zmq # on OS/X
apt-get install libzmq-dev # on Ubuntu
You'll also want jupyter, for the front end:
pip install jupyter
Finally, install Jupyter::Kernel
:
zef install Jupyter::Kernel
At the end of the above installation, you'll see the location
of the bin/
directory which has jupyter-kernel.p6
. Make
sure that is in your PATH
.
To generate a configuration directory, and to install a kernel config file and icons into the default location:
jupyter-kernel.p6 --generate-config
- Use
--location=XXX
to specify another location. - Use
--force
to override an existing configuration.
By default a log file jupyter.log
will be written in the
current directory. An option --logfile=XXX
argument can be
added to the kernel configuration file to change this.
Start the web UI with:
jupyter-notebook
Then select new -> perl6.
You can also use it in the console like this:
jupyter-console --kernel=perl6
Or make a handy shell alias:
alias iperl6='jupyter-console --kernel=perl6'
-
Autocompletion. Typing
[tab]
in the client will send an autocomplete request. Possible autocompletions are:-
methods: after a
.
the invocant will be evaluated to find methods -
set operators: after a
(
, set operators (unicode and texas) will be shown -
equality/inequality operators: after
=
,<
, or>
, related operators will be shown -
autocompleting
*
or/
will give×
or÷
respectively
-
-
All cells are evaluated in item context. Outputs are then saved to an array named
$Out
. You can read from this directly or:-
via the subroutine
Out
(e.g.Out[3]
) -
via an underscore and the output number (e.g.
_3
) -
for the most recent output: via a plain underscore (
_
).
-
For an even quicker start using docker, see this blog post.
The eg/ directory of this repository has some example notebooks:
https://hub.docker.com/r/sumdoc/perl-6-notebook/
https://github.com/timo/iperl6kernel
-
Definitions of operators are not preserved (see bug 131530).
-
Newly declared methods might not be available in autocompletion unless SPESH is disabled (see tests in this PR).
Suman Khanal
Matt Oates
Timo Paulssen