ihaskell-0.10.3.0: A Haskell backend kernel for the Jupyter project.
Safe HaskellSafe-Inferred
LanguageHaskell2010

IHaskell.IPython.Stdin

Description

This module provides a way in which the Haskell standard input may be forwarded to the IPython frontend and thus allows the notebook to use the standard input.

This relies on the implementation of file handles in GHC, and is generally unsafe and terrible. However, it is difficult to find another way to do it, as file handles are generally meant to point to streams and files, and not networked communication protocols.

In order to use this module, it must first be initialized with two things. First of all, in order to know how to communicate with the IPython frontend, it must know the kernel profile used for communication. For this, use recordKernelProfile once the profile is known. Both this and recordParentHeader take a directory name where they can store this data.

Finally, the module must know what execute_request message is currently being replied to (which will request the input). Thus, every time the language kernel receives an execute_request message, it should inform this module via recordParentHeader, so that the module may generate messages with an appropriate parent header set. If this is not done, the IPython frontends will not recognize the target of the communication.

Finally, in order to activate this module, fixStdin must be called once. It must be passed the same directory name as recordParentHeader and recordKernelProfile. Note that if this is being used from within the GHC API, fixStdin must be called from within the GHC session not from the host code.

Synopsis

Documentation

fixStdin :: String -> IO () Source #

Manipulate standard input so that it is sourced from the IPython frontend. This function is build on layers of deep magical hackery, so be careful modifying it.