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

IHaskell.Display

Description

If you are interested in the IHaskell library for the purpose of augmenting the IHaskell notebook or writing your own display mechanisms and widgets, this module contains all functions you need.

In order to create a display mechanism for a particular data type, write a module named (for example) IHaskell.Display.YourThing in a package named ihaskell-yourThing. (Note the capitalization - it's important!) Then, in that module, add an instance of IHaskellDisplay for your data type. Similarly, to create a widget, add an instance of IHaskellWidget.

An example of creating a display is provided in the demo notebook.

Synopsis

Rich display and interactive display typeclasses and types

class IHaskellDisplay a where Source #

A class for displayable Haskell types.

IHaskell's displaying of results behaves as if these two overlapping/undecidable instances also existed:

instance (Show a) => IHaskellDisplay a
instance Show a where shows _ = id

Methods

display :: a -> IO Display Source #

Instances

Instances details
IHaskellDisplay Display Source # 
Instance details

Defined in IHaskell.Types

IHaskellDisplay Widget Source # 
Instance details

Defined in IHaskell.Types

IHaskellDisplay DisplayData Source # 
Instance details

Defined in IHaskell.Types

IHaskellDisplay a => IHaskellDisplay (IO a) Source #

these instances cause the image, html etc. which look like:

Display
[Display]
IO [Display]
IO (IO Display)

be run the IO and get rendered (if the frontend allows it) in the pretty form.

Instance details

Defined in IHaskell.Types

Methods

display :: IO a -> IO Display Source #

IHaskellDisplay a => IHaskellDisplay [a] Source # 
Instance details

Defined in IHaskell.Types

Methods

display :: [a] -> IO Display Source #

data Display Source #

Wrapper for ipython-kernel's DisplayData which allows sending multiple results from the same expression.

Instances

Instances details
ToJSON Display Source # 
Instance details

Defined in IHaskell.Types

Monoid Display Source # 
Instance details

Defined in IHaskell.Types

Semigroup Display Source # 
Instance details

Defined in IHaskell.Types

Generic Display Source # 
Instance details

Defined in IHaskell.Types

Associated Types

type Rep Display :: Type -> Type #

Methods

from :: Display -> Rep Display x #

to :: Rep Display x -> Display #

Show Display Source # 
Instance details

Defined in IHaskell.Types

Binary Display Source # 
Instance details

Defined in IHaskell.Types

Methods

put :: Display -> Put #

get :: Get Display #

putList :: [Display] -> Put #

IHaskellDisplay Display Source # 
Instance details

Defined in IHaskell.Types

type Rep Display Source # 
Instance details

Defined in IHaskell.Types

type Rep Display = D1 ('MetaData "Display" "IHaskell.Types" "ihaskell-0.10.3.0-1Y1GeklUisK1aFT1NNWHeo" 'False) (C1 ('MetaCons "Display" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DisplayData])) :+: C1 ('MetaCons "ManyDisplay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Display])))

data DisplayData #

Data for display: a string with associated MIME type.

Constructors

DisplayData MimeType Text 

Instances

Instances details
Generic DisplayData 
Instance details

Defined in IHaskell.IPython.Types

Associated Types

type Rep DisplayData :: Type -> Type #

Show DisplayData 
Instance details

Defined in IHaskell.IPython.Types

Binary DisplayData 
Instance details

Defined in IHaskell.IPython.Types

IHaskellDisplay DisplayData Source # 
Instance details

Defined in IHaskell.Types

type Rep DisplayData 
Instance details

Defined in IHaskell.IPython.Types

type Rep DisplayData = D1 ('MetaData "DisplayData" "IHaskell.IPython.Types" "ipython-kernel-0.10.3.0-7rXj2chaGhf4ymDgbYiVwI" 'False) (C1 ('MetaCons "DisplayData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MimeType) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

class IHaskellDisplay a => IHaskellWidget a where Source #

Display as an interactive widget.

Minimal complete definition

getCommUUID

Methods

targetName :: a -> String Source #

Target name for this widget. The actual input parameter should be ignored. By default evaluate to "jupyter.widget", which is used by IPython for its backbone widgets.

targetModule :: a -> String Source #

Target module for this widget. Evaluates to an empty string by default.

getBufferPaths :: a -> [BufferPath] Source #

Buffer paths for this widget. Evaluates to an empty array by default.

getCommUUID :: a -> UUID Source #

Get the uuid for comm associated with this widget. The widget is responsible for storing the UUID during initialization.

open Source #

Arguments

:: a

Widget to open a comm port with.

-> (Value -> IO ())

A function for sending messages.

-> IO () 

Called when the comm is opened. Allows additional messages to be sent after comm open.

comm Source #

Arguments

:: a

Widget which is being communicated with.

-> Value

Data recieved from the frontend.

-> (Value -> IO ())

Way to respond to the message.

-> IO () 

Respond to a comm data message. Called when a message is recieved on the comm associated with the widget.

close Source #

Arguments

:: a

Widget to close comm port with.

-> Value

Data recieved from the frontend.

-> IO () 

Called when a comm_close is recieved from the frontend.

Instances

Instances details
IHaskellWidget Widget Source # 
Instance details

Defined in IHaskell.Types

Interactive use functions

printDisplay :: IHaskellDisplay a => a -> IO () Source #

Write to the display channel. The contents will be displayed in the notebook once the current execution call ends.

Constructors for displays

plain :: String -> DisplayData Source #

Generate a plain text display.

html :: String -> DisplayData Source #

Generate an HTML display.

bmp :: Width -> Height -> Base64 -> DisplayData Source #

Generate a BMP display of the given width and height. Data must be provided in a Base64 encoded manner, suitable for embedding into HTML. The base64 function may be used to encode data into this format.

png :: Width -> Height -> Base64 -> DisplayData Source #

Generate a PNG display of the given width and height. Data must be provided in a Base64 encoded manner, suitable for embedding into HTML. The base64 function may be used to encode data into this format.

jpg :: Width -> Height -> Base64 -> DisplayData Source #

Generate a JPG display of the given width and height. Data must be provided in a Base64 encoded manner, suitable for embedding into HTML. The base64 function may be used to encode data into this format.

gif :: Width -> Height -> Base64 -> DisplayData Source #

Generate a GIF display of the given width and height. Data must be provided in a Base64 encoded manner, suitable for embedding into HTML. The base64 function may be used to encode data into this format.

svg :: String -> DisplayData Source #

Generate an SVG display.

latex :: String -> DisplayData Source #

Generate a LaTeX display.

markdown :: String -> DisplayData Source #

Generate a Markdown display.

javascript :: String -> DisplayData Source #

Generate a Javascript display.

json :: String -> DisplayData Source #

Generate a Json display.

vega :: String -> DisplayData Source #

Generate a Vega display.

vegalite :: String -> DisplayData Source #

Generate a Vegalite display.

vdom :: String -> DisplayData Source #

Generate a Vdom display.

widgetdisplay :: String -> DisplayData Source #

Generate a Widget display given the uuid and the view version

custom :: Text -> String -> DisplayData Source #

Generate a custom display. The first argument is the mimetype and the second argument is the payload.

many :: [Display] -> Display Source #

Encode many displays into a single one. All will be output.

Image and data encoding functions

type Width = Int #

Possible MIME types for the display data.

type Height = Int #

encode64 :: String -> Base64 Source #

Convert from a string into base 64 encoded data.

base64 :: ByteString -> Base64 Source #

Convert from a ByteString into base 64 encoded data.

Internal only use

displayFromChanEncoded :: IO ByteString Source #

Take everything that was put into the displayChan at that point out, and make a Display out of it.

serializeDisplay :: Display -> ByteString Source #

For internal use within IHaskell. Serialize displays to a ByteString.

data Widget Source #

Constructors

forall a.IHaskellWidget a => Widget a 

Instances

Instances details
Show Widget Source # 
Instance details

Defined in IHaskell.Types

Eq Widget Source # 
Instance details

Defined in IHaskell.Types

Methods

(==) :: Widget -> Widget -> Bool #

(/=) :: Widget -> Widget -> Bool #

IHaskellDisplay Widget Source # 
Instance details

Defined in IHaskell.Types

IHaskellWidget Widget Source # 
Instance details

Defined in IHaskell.Types