knit-haskell-0.3.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 PandocWithRequirements Source #

Type-alias for use with the Docs effect.

data NamedDoc a Source #

Data type to hold one named document of type a.

Constructors

NamedDoc 

Fields

Instances
Functor NamedDoc Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

fmap :: (a -> b) -> NamedDoc a -> NamedDoc b #

(<$) :: a -> NamedDoc b -> NamedDoc a #

Foldable NamedDoc Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

fold :: Monoid m => NamedDoc m -> m #

foldMap :: Monoid m => (a -> m) -> NamedDoc a -> m #

foldr :: (a -> b -> b) -> b -> NamedDoc a -> b #

foldr' :: (a -> b -> b) -> b -> NamedDoc a -> b #

foldl :: (b -> a -> b) -> b -> NamedDoc a -> b #

foldl' :: (b -> a -> b) -> b -> NamedDoc a -> b #

foldr1 :: (a -> a -> a) -> NamedDoc a -> a #

foldl1 :: (a -> a -> a) -> NamedDoc a -> a #

toList :: NamedDoc a -> [a] #

null :: NamedDoc a -> Bool #

length :: NamedDoc a -> Int #

elem :: Eq a => a -> NamedDoc a -> Bool #

maximum :: Ord a => NamedDoc a -> a #

minimum :: Ord a => NamedDoc a -> a #

sum :: Num a => NamedDoc a -> a #

product :: Num a => NamedDoc a -> a #

Traversable NamedDoc Source # 
Instance details

Defined in Knit.Effect.Docs

Methods

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

sequenceA :: Applicative f => NamedDoc (f a) -> f (NamedDoc a) #

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

sequence :: Monad m => NamedDoc (m a) -> m (NamedDoc a) #

Docs Effect Interpreters

newPandoc Source #

Arguments

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

name of 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.

pandocsToNamed 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 [NamedDoc 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