ipython-kernel-0.10.3.0: A library for creating kernels for IPython frontends
Safe HaskellSafe-Inferred
LanguageHaskell2010

IHaskell.IPython.EasyKernel

Description

simple IPython kernels. In particular, it provides a record type that defines configurations and a function that interprets a configuration as an action in some monad that can do IO.

The configuration consists primarily of functions that implement the various features of a kernel, such as running code, looking up documentation, and performing completion. An example for a simple language that nevertheless has side effects, global state, and timing effects is included in the examples directory.

Kernel Specs

To run your kernel, you will need to install the kernelspec into the Jupyter namespace. If your kernel name is kernel, you will need to run the command:

kernel install

This will inform Jupyter of the kernel so that it may be used.

Further profile improvements Consult the IPython documentation along with the generated

profile source code for further configuration of the frontend, including syntax highlighting, logos, help text, and so forth.

Synopsis

Documentation

easyKernel Source #

Arguments

:: MonadIO m 
=> FilePath

The connection file provided by the IPython frontend

-> KernelConfig m output result

The kernel configuration specifying how to react to messages

-> m () 

Execute an IPython kernel for a config. Your main action should call this as the last thing it does.

installKernelspec Source #

Arguments

:: MonadIO m 
=> KernelConfig m output result

Kernel configuration to install

-> Bool

Whether to use Jupyter `--replace`

-> Maybe FilePath

(Optional) prefix to install into for Jupyter `--prefix`

-> m () 

data KernelConfig m output result Source #

The kernel configuration specifies the behavior that is specific to your language. The type parameters provide the monad in which your kernel will run, the type of intermediate outputs from running cells, and the type of final results of cells, respectively.

Constructors

KernelConfig 

Fields

  • kernelLanguageInfo :: LanguageInfo

    Info on the language of the kernel.

  • writeKernelspec :: FilePath -> IO KernelSpec

    Write all the files into the kernel directory, including `kernel.js`, `logo-64x64.svg`, and any other required files. The directory to write to will be passed to this function, and the return value should be the kernelspec to be written to `kernel.json`.

  • displayOutput :: output -> [DisplayData]

    How to render intermediate output

  • displayResult :: result -> [DisplayData]

    How to render final cell results

  • completion :: Text -> Int -> m (Text, [Text])

    Perform completion. The returned tuple consists of the matched text and completions. The arguments are the code in the cell and the position of the cursor in the cell.

  • inspectInfo :: Text -> Int -> m (Maybe [DisplayData])

    Return the information or documentation for its argument, described by the cell contents and cursor position. The returned value is simply the data to display.

  • run :: Text -> IO () -> (output -> IO ()) -> m (result, ExecuteReplyStatus, String)

    Execute a cell. The arguments are the contents of the cell, an IO action that will clear the current intermediate output, and an IO action that will add a new item to the intermediate output. The result consists of the actual result, the status to be sent to IPython, and the contents of the pager. Return the empty string to indicate that there is no pager output. Errors should be handled by defining an appropriate error constructor in your result type.

  • debug :: Bool

    Whether to print extra debugging information to | A One-line description of the kernel

  • kernelBanner :: String
     
  • kernelProtocolVersion :: String

    The version of the messaging specification used by the kernel

  • kernelImplName :: String

    Name of the kernel implementation

  • kernelImplVersion :: String

    Version of the kernel implementation