knit-haskell-0.5.0.0: a minimal Rmarkdown sort-of-thing for haskell, by way of Pandoc

Copyright(c) Adam Conner-Sax 2019
LicenseBSD-3-Clause
Maintaineradam_conner_sax@yahoo.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Knit.Effect.Pandoc

Contents

Description

Polysemy Pandoc effect. This is writer-like, allowing the interspersed addition of various Pandoc-readable formats into one doc and then rendering to many Pandoc-writeable formats. Currently only a subset of formats are supported. Inputs can express requirements, e.g., hvega requires html output because it uses javascript. Those requirements are then checked before output is rendered and an error thrown if the input is not supported.

Synopsis

Effects

data ToPandoc m r Source #

Pandoc writer, add any read format to current doc

data FromPandoc m r Source #

Pandoc output effect, take given doc and produce formatted output

Requirement Support

data Requirement Source #

ADT to allow inputs to request support, if necessary or possible, in the output format. E.g., Latex output in Html needs MathJax. But Latex needs to nothing to output in Latex. Vega-lite needs some script headers to output in Html and can't be output in other formats. For now, we support all the things we can in any output format so this just results in a runtime test.

Constructors

VegaSupport

Supported only for Html output.

LatexSupport

Supported in Html output (via MathJax) and Latex output.

Format ADTs

Combinators

addFrom :: Member ToPandoc effs => PandocReadFormat a -> ReaderOptions -> a -> Sem effs () Source #

Add a piece of a Pandoc readable type to the current doc

require :: Member ToPandoc effs => Requirement -> Sem effs () Source #

Add a requirement that the output format must satisfy.

writeTo :: Member FromPandoc effs => PandocWriteFormat a -> WriterOptions -> Pandoc -> Sem effs a Source #

Write given doc in requested format

toPandoc :: PandocMonad m => PandocReadFormat a -> ReaderOptions -> a -> m Pandoc Source #

Convert a to Pandoc with the given options

fromPandoc :: PandocMonad m => PandocWriteFormat a -> WriterOptions -> PandocWithRequirements -> m a Source #

Convert Pandoc to requested format with the given options. | Throw a PandocError if the output format is unsupported given the inputs.

Interpreters

runPandocWriter :: PandocEffects effs => Sem (ToPandoc ': effs) () -> Sem effs PandocWithRequirements Source #

Run ToPandoc by interpreting in Writer and then running that Writer.

Docs effect type-aliases

type Pandocs = Docs PandocInfo PandocWithRequirements Source #

Type-alias for use with the Docs effect.

Pandoc Specific Info

data PandocInfo Source #

Type to hold info about each document that will be required for rendering and output

Constructors

PandocInfo 

Docs Effect Interpreters

newPandoc Source #

Arguments

:: (PandocEffects effs, Member Pandocs effs) 
=> PandocInfo

name and template variables for document

-> Sem (ToPandoc ': effs) () 
-> Sem effs () 

Add the Pandoc stored in the writer-style ToPandoc effect to the named docs collection with the given name.

pandocsToDocs Source #

Arguments

:: PandocEffects effs 
=> PandocWriteFormat a

format for Pandoc output

-> WriterOptions

options for the Pandoc Writer

-> Sem (Pandocs ': effs) ()

effects stack to be (partially) run to get documents

-> Sem effs [DocWithInfo PandocInfo a]

documents in requested format, within the effects monad

Given a write format and options, convert a list of named Pandocs to a list of named docs in the requested format

fromPandocE Source #

Arguments

:: PandocEffects effs 
=> PandocWriteFormat a

format for Pandoc output

-> WriterOptions

options for the Pandoc Writer

-> Sem (ToPandoc ': effs) ()

effects stack to be (partially) run to get document

-> Sem effs a

document in requested format, within the effects monad

Given a write format and options, run the writer-style ToPandoc effect and produce a doc of requested type

Re-exports

data DocWithInfo i a Source #

Data type to hold one document with info of typ i and doc of type a.

Constructors

DocWithInfo 

Fields

Instances
Functor (DocWithInfo i) Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

fmap :: (a -> b) -> DocWithInfo i a -> DocWithInfo i b #

(<$) :: a -> DocWithInfo i b -> DocWithInfo i a #

Foldable (DocWithInfo i) Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

fold :: Monoid m => DocWithInfo i m -> m #

foldMap :: Monoid m => (a -> m) -> DocWithInfo i a -> m #

foldr :: (a -> b -> b) -> b -> DocWithInfo i a -> b #

foldr' :: (a -> b -> b) -> b -> DocWithInfo i a -> b #

foldl :: (b -> a -> b) -> b -> DocWithInfo i a -> b #

foldl' :: (b -> a -> b) -> b -> DocWithInfo i a -> b #

foldr1 :: (a -> a -> a) -> DocWithInfo i a -> a #

foldl1 :: (a -> a -> a) -> DocWithInfo i a -> a #

toList :: DocWithInfo i a -> [a] #

null :: DocWithInfo i a -> Bool #

length :: DocWithInfo i a -> Int #

elem :: Eq a => a -> DocWithInfo i a -> Bool #

maximum :: Ord a => DocWithInfo i a -> a #

minimum :: Ord a => DocWithInfo i a -> a #

sum :: Num a => DocWithInfo i a -> a #

product :: Num a => DocWithInfo i a -> a #

Traversable (DocWithInfo i) Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

traverse :: Applicative f => (a -> f b) -> DocWithInfo i a -> f (DocWithInfo i b) #

sequenceA :: Applicative f => DocWithInfo i (f a) -> f (DocWithInfo i a) #

mapM :: Monad m => (a -> m b) -> DocWithInfo i a -> m (DocWithInfo i b) #

sequence :: Monad m => DocWithInfo i (m a) -> m (DocWithInfo i a) #