ipynb-0.2: Data structure for working with Jupyter notebooks (ipynb).
CopyrightCopyright (C) 2019 John MacFarlane
LicenseBSD3
MaintainerJohn MacFarlane <jgm@berkeley.edu>
Stabilityalpha
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Ipynb

Description

Data structure and JSON serializers for ipynb (Jupyter notebook) format. Version 4 of the format is documented here: https://nbformat.readthedocs.io/en/latest/format_description.html.

The library supports both version 4 ('Notebook NbV4') and version 3 ('Notebook NbV3') of nbformat. Note that this is a phantom type: the NbV3 or NbV4 parameter only affects JSON serialization, not the data structure itself. So code that manipulates notebooks can be polymorphic, operating on `Notebook a`.

Synopsis

Documentation

data Notebook a #

A Jupyter notebook.

Constructors

Notebook 

Instances

Instances details
FromJSON (Notebook NbV3) # 
Instance details

Defined in Data.Ipynb

FromJSON (Notebook NbV4) # 
Instance details

Defined in Data.Ipynb

ToJSON (Notebook NbV3) # 
Instance details

Defined in Data.Ipynb

ToJSON (Notebook NbV4) # 
Instance details

Defined in Data.Ipynb

Monoid (Notebook a) # 
Instance details

Defined in Data.Ipynb

Methods

mempty :: Notebook a #

mappend :: Notebook a -> Notebook a -> Notebook a #

mconcat :: [Notebook a] -> Notebook a #

Semigroup (Notebook a) # 
Instance details

Defined in Data.Ipynb

Methods

(<>) :: Notebook a -> Notebook a -> Notebook a #

sconcat :: NonEmpty (Notebook a) -> Notebook a #

stimes :: Integral b => b -> Notebook a -> Notebook a #

Generic (Notebook a) # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep (Notebook a) 
Instance details

Defined in Data.Ipynb

type Rep (Notebook a) = D1 ('MetaData "Notebook" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'False) (C1 ('MetaCons "Notebook" 'PrefixI 'True) (S1 ('MetaSel ('Just "notebookMetadata") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 JSONMeta) :*: (S1 ('MetaSel ('Just "notebookFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int, Int)) :*: S1 ('MetaSel ('Just "notebookCells") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Cell a]))))

Methods

from :: Notebook a -> Rep (Notebook a) x #

to :: Rep (Notebook a) x -> Notebook a #

Show (Notebook a) # 
Instance details

Defined in Data.Ipynb

Methods

showsPrec :: Int -> Notebook a -> ShowS #

show :: Notebook a -> String #

showList :: [Notebook a] -> ShowS #

Eq (Notebook a) # 
Instance details

Defined in Data.Ipynb

Methods

(==) :: Notebook a -> Notebook a -> Bool #

(/=) :: Notebook a -> Notebook a -> Bool #

type Rep (Notebook a) # 
Instance details

Defined in Data.Ipynb

type Rep (Notebook a) = D1 ('MetaData "Notebook" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'False) (C1 ('MetaCons "Notebook" 'PrefixI 'True) (S1 ('MetaSel ('Just "notebookMetadata") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 JSONMeta) :*: (S1 ('MetaSel ('Just "notebookFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int, Int)) :*: S1 ('MetaSel ('Just "notebookCells") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Cell a]))))

data NbV3 #

Indexes Notebook for serialization as nbformat version 3.

data NbV4 #

Indexes Notebook for serialization as nbformat version 4.

newtype JSONMeta #

Constructors

JSONMeta (Map Text Value) 

Instances

Instances details
FromJSON JSONMeta # 
Instance details

Defined in Data.Ipynb

ToJSON JSONMeta # 
Instance details

Defined in Data.Ipynb

Monoid JSONMeta # 
Instance details

Defined in Data.Ipynb

Semigroup JSONMeta # 
Instance details

Defined in Data.Ipynb

Generic JSONMeta # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep JSONMeta 
Instance details

Defined in Data.Ipynb

type Rep JSONMeta = D1 ('MetaData "JSONMeta" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "JSONMeta" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text Value))))

Methods

from :: JSONMeta -> Rep JSONMeta x #

to :: Rep JSONMeta x -> JSONMeta #

Show JSONMeta # 
Instance details

Defined in Data.Ipynb

Eq JSONMeta # 
Instance details

Defined in Data.Ipynb

Ord JSONMeta # 
Instance details

Defined in Data.Ipynb

type Rep JSONMeta # 
Instance details

Defined in Data.Ipynb

type Rep JSONMeta = D1 ('MetaData "JSONMeta" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "JSONMeta" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text Value))))

data Cell a #

A Jupyter notebook cell.

Instances

Instances details
FromJSON (Cell NbV3) # 
Instance details

Defined in Data.Ipynb

FromJSON (Cell NbV4) # 
Instance details

Defined in Data.Ipynb

ToJSON (Cell NbV3) # 
Instance details

Defined in Data.Ipynb

ToJSON (Cell NbV4) # 
Instance details

Defined in Data.Ipynb

Generic (Cell a) # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep (Cell a) 
Instance details

Defined in Data.Ipynb

Methods

from :: Cell a -> Rep (Cell a) x #

to :: Rep (Cell a) x -> Cell a #

Show (Cell a) # 
Instance details

Defined in Data.Ipynb

Methods

showsPrec :: Int -> Cell a -> ShowS #

show :: Cell a -> String #

showList :: [Cell a] -> ShowS #

Eq (Cell a) # 
Instance details

Defined in Data.Ipynb

Methods

(==) :: Cell a -> Cell a -> Bool #

(/=) :: Cell a -> Cell a -> Bool #

type Rep (Cell a) # 
Instance details

Defined in Data.Ipynb

newtype Source #

A Source is a textual content which may be represented in JSON either as a single string or as a list of strings (which are concatenated).

Constructors

Source 

Fields

Instances

Instances details
FromJSON Source # 
Instance details

Defined in Data.Ipynb

ToJSON Source # 
Instance details

Defined in Data.Ipynb

Monoid Source # 
Instance details

Defined in Data.Ipynb

Semigroup Source # 
Instance details

Defined in Data.Ipynb

Generic Source # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep Source 
Instance details

Defined in Data.Ipynb

type Rep Source = D1 ('MetaData "Source" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "Source" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))

Methods

from :: Source -> Rep Source x #

to :: Rep Source x -> Source #

Show Source # 
Instance details

Defined in Data.Ipynb

Eq Source # 
Instance details

Defined in Data.Ipynb

Methods

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

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

type Rep Source # 
Instance details

Defined in Data.Ipynb

type Rep Source = D1 ('MetaData "Source" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "Source" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSource") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))

data CellType a #

Information about the type of a notebook cell, plus data specific to that type. note that Heading is for v3 only; a Heading will be rendered as Markdown in v4.

Constructors

Markdown 
Heading 

Fields

Raw 
Code 

Instances

Instances details
Generic (CellType a) # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep (CellType a) 
Instance details

Defined in Data.Ipynb

type Rep (CellType a) = D1 ('MetaData "CellType" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'False) ((C1 ('MetaCons "Markdown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Heading" 'PrefixI 'True) (S1 ('MetaSel ('Just "headingLevel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) :+: (C1 ('MetaCons "Raw" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Code" 'PrefixI 'True) (S1 ('MetaSel ('Just "codeExecutionCount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "codeOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Output a]))))

Methods

from :: CellType a -> Rep (CellType a) x #

to :: Rep (CellType a) x -> CellType a #

Show (CellType a) # 
Instance details

Defined in Data.Ipynb

Methods

showsPrec :: Int -> CellType a -> ShowS #

show :: CellType a -> String #

showList :: [CellType a] -> ShowS #

Eq (CellType a) # 
Instance details

Defined in Data.Ipynb

Methods

(==) :: CellType a -> CellType a -> Bool #

(/=) :: CellType a -> CellType a -> Bool #

type Rep (CellType a) # 
Instance details

Defined in Data.Ipynb

type Rep (CellType a) = D1 ('MetaData "CellType" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'False) ((C1 ('MetaCons "Markdown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Heading" 'PrefixI 'True) (S1 ('MetaSel ('Just "headingLevel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) :+: (C1 ('MetaCons "Raw" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Code" 'PrefixI 'True) (S1 ('MetaSel ('Just "codeExecutionCount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Int)) :*: S1 ('MetaSel ('Just "codeOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Output a]))))

data Output a #

Output from a Code cell.

Instances

Instances details
FromJSON (Output NbV3) # 
Instance details

Defined in Data.Ipynb

FromJSON (Output NbV4) # 
Instance details

Defined in Data.Ipynb

ToJSON (Output NbV3) # 
Instance details

Defined in Data.Ipynb

ToJSON (Output NbV4) # 
Instance details

Defined in Data.Ipynb

Generic (Output a) # 
Instance details

Defined in Data.Ipynb

Methods

from :: Output a -> Rep (Output a) x #

to :: Rep (Output a) x -> Output a #

Show (Output a) # 
Instance details

Defined in Data.Ipynb

Methods

showsPrec :: Int -> Output a -> ShowS #

show :: Output a -> String #

showList :: [Output a] -> ShowS #

Eq (Output a) # 
Instance details

Defined in Data.Ipynb

Methods

(==) :: Output a -> Output a -> Bool #

(/=) :: Output a -> Output a -> Bool #

type Rep (Output a) # 
Instance details

Defined in Data.Ipynb

type MimeType = Text #

data MimeData #

Data in an execution result or display data cell.

Instances

Instances details
ToJSON MimeData # 
Instance details

Defined in Data.Ipynb

Generic MimeData # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep MimeData 
Instance details

Defined in Data.Ipynb

Methods

from :: MimeData -> Rep MimeData x #

to :: Rep MimeData x -> MimeData #

Show MimeData # 
Instance details

Defined in Data.Ipynb

Eq MimeData # 
Instance details

Defined in Data.Ipynb

Ord MimeData # 
Instance details

Defined in Data.Ipynb

type Rep MimeData # 
Instance details

Defined in Data.Ipynb

newtype MimeBundle #

A MimeBundle wraps a map from mime types to mime data.

Constructors

MimeBundle 

Instances

Instances details
FromJSON MimeBundle # 
Instance details

Defined in Data.Ipynb

ToJSON MimeBundle # 
Instance details

Defined in Data.Ipynb

Monoid MimeBundle # 
Instance details

Defined in Data.Ipynb

Semigroup MimeBundle # 
Instance details

Defined in Data.Ipynb

Generic MimeBundle # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep MimeBundle 
Instance details

Defined in Data.Ipynb

type Rep MimeBundle = D1 ('MetaData "MimeBundle" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "MimeBundle" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMimeBundle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map MimeType MimeData))))
Show MimeBundle # 
Instance details

Defined in Data.Ipynb

Eq MimeBundle # 
Instance details

Defined in Data.Ipynb

Ord MimeBundle # 
Instance details

Defined in Data.Ipynb

type Rep MimeBundle # 
Instance details

Defined in Data.Ipynb

type Rep MimeBundle = D1 ('MetaData "MimeBundle" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "MimeBundle" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMimeBundle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map MimeType MimeData))))

newtype MimeAttachments #

Instances

Instances details
FromJSON MimeAttachments # 
Instance details

Defined in Data.Ipynb

ToJSON MimeAttachments # 
Instance details

Defined in Data.Ipynb

Monoid MimeAttachments # 
Instance details

Defined in Data.Ipynb

Semigroup MimeAttachments # 
Instance details

Defined in Data.Ipynb

Generic MimeAttachments # 
Instance details

Defined in Data.Ipynb

Associated Types

type Rep MimeAttachments 
Instance details

Defined in Data.Ipynb

type Rep MimeAttachments = D1 ('MetaData "MimeAttachments" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "MimeAttachments" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text MimeBundle))))
Show MimeAttachments # 
Instance details

Defined in Data.Ipynb

Eq MimeAttachments # 
Instance details

Defined in Data.Ipynb

Ord MimeAttachments # 
Instance details

Defined in Data.Ipynb

type Rep MimeAttachments # 
Instance details

Defined in Data.Ipynb

type Rep MimeAttachments = D1 ('MetaData "MimeAttachments" "Data.Ipynb" "ipynb-0.2-ECEsTZjwSEXDGeec6C4GR9" 'True) (C1 ('MetaCons "MimeAttachments" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text MimeBundle))))

breakLines :: Text -> [Text] #

Break up a string into a list of strings, each representing one line of the string (including trailing newline if any).