Git Product home page Git Product logo

jupyter-elm-kernel's Introduction

This kernel adds support for Elm to Jupyter notebooks.

While basic functionality is in place, this is still very much a work in progress. I'm still figuring it all out. Any help, ideas, etc. would be great.

Requirements

  • Python 3.6+

Installation

Either install from a repository using pip:

pip install elm_kernel

or install the package from source:

pip install -e .

Then install the kernel spec:

python -m elm_kernel.install

Usage

Run jupyter notebook and select the Elm kernel for a new notebook.

Multi-cell code examples

By default, when you execute a code cell with the Elm kernel the code will not be compiled. Instead, the kernel simply queues up code cells. This way you can break longer examples over multiple cells, interleaving the code cells with supporting Markdown cells.

In order to ask the kernel to actually compile your code, you need to terminate a code cell with the line:

-- compile-code

When the kernel sees a cell like this it contatenates, in cell-execution order, all of the executed but uncompiled code cells (i.e. everything since the start of the kernel or the last -- compile-code cell). It then compiles the concatenated code, returning the result to the notebook.

For a concrete example of this, see examples/the-elm-architecture.ipynb.

This is a bit hacky, and we're actively searching for a better alternative. Ideas are welcome!

Examples

The examples directory contains a few examples of how to use this kernel. Just go to that directory and run jupyter notebook to see them.

jupyter-elm-kernel's People

Contributors

amphitheres avatar eeue56 avatar paitonic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyter-elm-kernel's Issues

How to handle multi-cell examples?

It would be nice to have some way of combining multiple cells into a single program. Right now each cell is an independent program. This may be clunky with Elm, esp. compared to Python.

How do i import Additional modules?

so far, i tried running jupyter in the project directory but i have no output but when moved to the src directory, i was able to run it but i had issue with external modules not being available.

when i move elm.json to the src directory too, jupyther hangs during compilation.

can you please assist?

pip package is outdated

I installed the elm-kernel module via pip and realized that it requires 'elm-make', which is elm 0.18.

Then I installed the kernel via pip install -e . and it worked as expected, using elm 0.19.1

Notebook failing to connect to kernel

Steps to reproduce:

git clone https://github.com/abingham/jupyter-elm-kernel
copy default.nix and requirements.txt there

In a nix-enabled shell run:

nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.03.tar.gz

I had to use nixos-18.03 to overcome the requirement to upgrade to elm 0.19 (elm-make renamed to elm make which would require kernel.json edits).

Also had to use pyzmq==17.1.3 instaed of pyzmq==18.0.0 (current latest version) to overcome zeromq/pyzmq#946 (had exact same error).

Reproducing the following error when opening the notebook after jupyter notebook:

[I 09:16:59.447 NotebookApp] Adapting to protocol v5.1 for kernel 8b6ce4f9-db58-4082-a242-8d67b7580676
/mnt/c/Users/myuser/pip-inside-nix-shell/venv/lib/python3.6/site-packages/notebook/base/zmqhandlers.py:284: RuntimeWarning: coroutine 'WebSocketHandler.get' was never awaited
super(AuthenticatedZMQStreamHandler, self).get(*args, **kwargs)

Allow user to customize elm-make command

They should be able to specify the elm-make command-line, while still providing reasonable defaults. We need to figure out the proper way to do this in the Jupyter framework. Perhaps in the profile information or something.

Allow to import modules that are not core modules

It is not possible to import other modules, e.g Http, since it's not part of the core language its needs to be installed with elm-package.

Take for example: http://elm-lang.org/examples/http

The error I got when running this:
b"I cannot find module 'Http'.\n\nModule 'Main' is trying to import it.\n\nPotential problems could be:\n * Misspelled the module name\n * Need to add a source directory or new dependency to elm-package.json\n"

When subprocess.run is running elm-make, it does install the core dependencies but it also tells that I have unsatisfied dependencies and it does not install it for me because it does not know what should be installed.

Currently the only way I found to make this work is to install the dependency with elm-package install elm-lang/http and make elm kernel copy elm-package.json to the temporary directory where the code is compiled.

So, the idea is if user wants to import modules, he will have to specify them in elm-package.json in the directory where notebook is running, then elm-kernel will copy elm-package.json and compile the code.

I can make a pull request if that makes sense.

pypi pip install version no option for elm notebook

Does it currently only work if installed from source?

I installed the Node kernel, have Python3 by default and did pip install elm_kernel, see that it's installed with conda list but don't get an option for an elm notebook when I click the new dropdown after launching jupyter notebook.

Basic tests

It would be nice to have a few tests to verify that everything works as expected. I suppose we'll need to use something like nbconvert and its Python API to execute and inspect notebooks.

You can see some rough work on the smoke-test branch. This work is incomplete and doesn't do it's job, but it might serve as an inspiration.

Syntax highlighting is missing ...

I am using nteract to write my notebooks. I don't have syntax highlighting in there using the elm-kernel ... I ask myself if this is a task of the kernel module ? I am not experienced with those things...

SVG example not woking

I get the following error when i try the SVG example:

I cannot find module 'Svg'.

Module 'Main' is trying to import it.

Potential problems could be:

  • Misspelled the module name
  • Need to add a source directory or new dependency to elm-package.json

I am using:
Notebook server version: 5.2.2
Python 3.6.4 on Win64

On first "run" it looks like the core packages getting installed as the error message looks like the following:

I cannot find module 'Svg'.

Module 'Main' is trying to import it.

Potential problems could be:

  • Misspelled the module name
  • Need to add a source directory or new dependency to elm-package.json
    Starting downloads...

● elm-lang/html 2.0.0
● elm-lang/virtual-dom 2.0.4
● elm-lang/core 5.1.1

Packages configured successfully!

language mapping not found by Atom's Hydrogen package

Hydrogen is a jupyter front-end plugin for Atom.
It fails to execute elm code because the language field in the kernel json is text instead of elm.
We should change that in install.py to say "language":"elm".

In the meantime, I found a workaround:
We can create a language mapping in Hydrogen's package settings from text to elm so that it can find the correct kernel for the language. (Language Mappings: {"text":"elm"})

Absolute path required for `source-directories` in elm.json

I have an elm notebook in my elm project directory. To get the notebook compiling, I had to 'hardcode' the absolute path to the source-directories property. I just had an array in there:
["src"], now I have like ["absolutepath/project/src"] ...

The compiler told me:

-- MISSING SOURCE DIRECTORY ------------------------------------------- elm.json

I need a valid elm.json file, but the "source-directories" field lists the
following directory:

    src

I cannot find it though. Is it missing? Is there a typo?


                            
Dependencies ready!

elm-repl support

Right now we support code as it would appear in an Elm source file, but it might be nice to have an elm-repl version as well. Not sure if this needs to be a separate kernel or how it might interact with the existing mode. Maybe look for other kernels with similar needs (e.g. IHaskell?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.