knit-haskell 0.6.0.1 → 0.7.0.0
raw patch · 9 files changed
+270/−246 lines, 9 filesdep ~colonnadedep ~heredep ~hvegaPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: colonnade, here, hvega, mtl, plots, polysemy, polysemy-RandomFu, polysemy-zoo, random-fu, random-source
API changes (from Hackage documentation)
- Knit.Report: data Lift (m :: Type -> Type) (z :: Type -> Type) a
+ Knit.Report: data Embed (m :: Type -> Type) (z :: Type -> Type) a
- Knit.Effect.Logger: data Sem (r :: [Type -> Type -> Type -> Type]) a
+ Knit.Effect.Logger: data Sem (r :: EffectRow) a
- Knit.Effect.Logger: type Member (e :: Type -> Type -> Type -> Type) (r :: [Type -> Type -> Type -> Type]) = Member' e r
+ Knit.Effect.Logger: type Member (e :: k) (r :: [k]) = MemberNoError e r
- Knit.Effect.PandocMonad: fileExists :: forall r_aOiF. Member Pandoc r_aOiF => FilePath -> Sem r_aOiF Bool
+ Knit.Effect.PandocMonad: fileExists :: forall r_aPL4. MemberWithError Pandoc r_aPL4 => FilePath -> Sem r_aPL4 Bool
- Knit.Effect.PandocMonad: getCommonState :: forall r_aOiI. Member Pandoc r_aOiI => Sem r_aOiI CommonState
+ Knit.Effect.PandocMonad: getCommonState :: forall r_aPLa. MemberWithError Pandoc r_aPLa => Sem r_aPLa CommonState
- Knit.Effect.PandocMonad: getCurrentTime :: forall r_aOix. Member Pandoc r_aOix => Sem r_aOix UTCTime
+ Knit.Effect.PandocMonad: getCurrentTime :: forall r_aPKS. MemberWithError Pandoc r_aPKS => Sem r_aPKS UTCTime
- Knit.Effect.PandocMonad: getCurrentTimeZone :: forall r_aOiy. Member Pandoc r_aOiy => Sem r_aOiy TimeZone
+ Knit.Effect.PandocMonad: getCurrentTimeZone :: forall r_aPKT. MemberWithError Pandoc r_aPKT => Sem r_aPKT TimeZone
- Knit.Effect.PandocMonad: getDataFileName :: forall r_aOiG. Member Pandoc r_aOiG => FilePath -> Sem r_aOiG [Char]
+ Knit.Effect.PandocMonad: getDataFileName :: forall r_aPL6. MemberWithError Pandoc r_aPL6 => FilePath -> Sem r_aPL6 FilePath
- Knit.Effect.PandocMonad: getModificationTime :: forall r_aOiH. Member Pandoc r_aOiH => FilePath -> Sem r_aOiH UTCTime
+ Knit.Effect.PandocMonad: getModificationTime :: forall r_aPL8. MemberWithError Pandoc r_aPL8 => FilePath -> Sem r_aPL8 UTCTime
- Knit.Effect.PandocMonad: getsCommonState :: forall r_aOiK r_aNux. Member Pandoc r_aOiK => (CommonState -> r_aNux) -> Sem r_aOiK r_aNux
+ Knit.Effect.PandocMonad: getsCommonState :: forall r_aPLd a_aP0R. MemberWithError Pandoc r_aPLd => (CommonState -> a_aP0R) -> Sem r_aPLd a_aP0R
- Knit.Effect.PandocMonad: glob :: forall r_aOiE. Member Pandoc r_aOiE => String -> Sem r_aOiE [[Char]]
+ Knit.Effect.PandocMonad: glob :: forall r_aPL2. MemberWithError Pandoc r_aPL2 => String -> Sem r_aPL2 [FilePath]
- Knit.Effect.PandocMonad: interpretInIO :: forall effs a. (Member (Logger LogEntry) effs, Member (Lift IO) effs, Member (Error PandocError) effs) => Sem (Pandoc : effs) a -> Sem effs a
+ Knit.Effect.PandocMonad: interpretInIO :: forall effs a. (Member (Logger LogEntry) effs, Member (Embed IO) effs, Member (Error PandocError) effs) => Sem (Pandoc : effs) a -> Sem effs a
- Knit.Effect.PandocMonad: interpretInPandocMonad :: forall m effs a. (PandocMonad m, Member (Lift m) effs, Member (Logger LogEntry) effs) => Sem (Pandoc : effs) a -> Sem effs a
+ Knit.Effect.PandocMonad: interpretInPandocMonad :: forall m effs a. (PandocMonad m, Member (Embed m) effs, Member (Logger LogEntry) effs) => Sem (Pandoc : effs) a -> Sem effs a
- Knit.Effect.PandocMonad: logOutput :: forall r_aOiM. Member Pandoc r_aOiM => LogMessage -> Sem r_aOiM ()
+ Knit.Effect.PandocMonad: logOutput :: forall r_aPLh. MemberWithError Pandoc r_aPLh => LogMessage -> Sem r_aPLh ()
- Knit.Effect.PandocMonad: lookupEnv :: forall r_aOiw. Member Pandoc r_aOiw => String -> Sem r_aOiw (Maybe [Char])
+ Knit.Effect.PandocMonad: lookupEnv :: forall r_aPKQ. MemberWithError Pandoc r_aPKQ => String -> Sem r_aPKQ (Maybe String)
- Knit.Effect.PandocMonad: modifyCommonState :: forall r_aOiL. Member Pandoc r_aOiL => (CommonState -> CommonState) -> Sem r_aOiL ()
+ Knit.Effect.PandocMonad: modifyCommonState :: forall r_aPLf. MemberWithError Pandoc r_aPLf => (CommonState -> CommonState) -> Sem r_aPLf ()
- Knit.Effect.PandocMonad: newStdGen :: forall r_aOiz. Member Pandoc r_aOiz => Sem r_aOiz StdGen
+ Knit.Effect.PandocMonad: newStdGen :: forall r_aPKU. MemberWithError Pandoc r_aPKU => Sem r_aPKU StdGen
- Knit.Effect.PandocMonad: newUniqueHash :: forall r_aOiA. Member Pandoc r_aOiA => Sem r_aOiA Int
+ Knit.Effect.PandocMonad: newUniqueHash :: forall r_aPKV. MemberWithError Pandoc r_aPKV => Sem r_aPKV Int
- Knit.Effect.PandocMonad: openURL :: forall r_aOiB. Member Pandoc r_aOiB => String -> Sem r_aOiB (ByteString, Maybe [Char])
+ Knit.Effect.PandocMonad: openURL :: forall r_aPKW. MemberWithError Pandoc r_aPKW => String -> Sem r_aPKW (ByteString, Maybe MimeType)
- Knit.Effect.PandocMonad: putCommonState :: forall r_aOiJ. Member Pandoc r_aOiJ => CommonState -> Sem r_aOiJ ()
+ Knit.Effect.PandocMonad: putCommonState :: forall r_aPLb. MemberWithError Pandoc r_aPLb => CommonState -> Sem r_aPLb ()
- Knit.Effect.PandocMonad: readFileLazy :: forall r_aOiC. Member Pandoc r_aOiC => FilePath -> Sem r_aOiC ByteString
+ Knit.Effect.PandocMonad: readFileLazy :: forall r_aPKY. MemberWithError Pandoc r_aPKY => FilePath -> Sem r_aPKY ByteString
- Knit.Effect.PandocMonad: readFileStrict :: forall r_aOiD. Member Pandoc r_aOiD => FilePath -> Sem r_aOiD ByteString
+ Knit.Effect.PandocMonad: readFileStrict :: forall r_aPL0. MemberWithError Pandoc r_aPL0 => FilePath -> Sem r_aPL0 ByteString
- Knit.Effect.PandocMonad: runIO :: [LogSeverity] -> Sem '[Pandoc, Logger LogEntry, PrefixLog, Error PandocError, Lift IO] a -> IO (Either PandocError a)
+ Knit.Effect.PandocMonad: runIO :: [LogSeverity] -> Sem '[Pandoc, Logger LogEntry, PrefixLog, Error PandocError, Embed IO] a -> IO (Either PandocError a)
- Knit.Effect.PandocMonad: trace :: forall r_aOiN. Member Pandoc r_aOiN => String -> Sem r_aOiN ()
+ Knit.Effect.PandocMonad: trace :: forall r_aPLj. MemberWithError Pandoc r_aPLj => String -> Sem r_aPLj ()
- Knit.Effect.PandocMonad: type PandocEffectsIO effs = (PandocEffects effs, Member (Lift IO) effs)
+ Knit.Effect.PandocMonad: type PandocEffectsIO effs = (PandocEffects effs, Member (Embed IO) effs)
- Knit.Report: data Sem (r :: [Type -> Type -> Type -> Type]) a
+ Knit.Report: data Sem (r :: EffectRow) a
- Knit.Report: liftKnit :: Member (Lift m) r => m a -> Sem r a
+ Knit.Report: liftKnit :: Member (Embed m) r => m a -> Sem r a
- Knit.Report: type KnitBase m effs = (MonadIO m, Member (Lift m) effs)
+ Knit.Report: type KnitBase m effs = (MonadIO m, Member (Embed m) effs)
- Knit.Report: type KnitEffects r = (PandocEffects r, Member UnusedId r)
+ Knit.Report: type KnitEffects r = (PandocEffects r, Members [UnusedId, Logger LogEntry, PrefixLog, Error PandocError, Embed IO] r)
- Knit.Report: type Member (e :: Type -> Type -> Type -> Type) (r :: [Type -> Type -> Type -> Type]) = Member' e r
+ Knit.Report: type Member (e :: k) (r :: [k]) = MemberNoError e r
Files
- ChangeLog.md +15/−0
- Readme.md +5/−1
- data/knit-haskell-templates/mindoc-pandoc-KH.html +3/−3
- data/knit-haskell-templates/pandoc-adaptive-bootstrap-KH.html +3/−3
- data/knit-haskell-templates/pandoc-bootstrap-KH.html +3/−3
- examples/SimpleExample.hs +1/−1
- knit-haskell.cabal +189/−188
- src/Knit/Effect/PandocMonad.hs +31/−32
- src/Knit/Report.hs +20/−15
ChangeLog.md view
@@ -1,3 +1,18 @@+v0.7.0.0+* Updated vega versions in pandoc templates+* removed (internal) datadir function because we now use the function+from the autogenerated ```Paths_knit-haskell``` module. Which has its own+complications but the other version didn't work at all.+* Added more constraints to Knit.Report.KnitEffects to simplify things. +If you use them to constrain a function to procuce something that can be knitted+you will have all the knit effects available.+* Where possible changed package bounds to >= A.B.C && < D.E. Most were already and+some were easy to change. There are some lower bounds that are more specific and I+won't generalize those unless I test them.+* Changed bounds for hvega, polysemy and polysemy-zoo. Downstream changes to account for this.+* SimpleExample now uses default template so that it also serves as a test that default templates are found.++ v 0.6.0.1 - (Released 2019-06-21) * Moved the Pandoc default templates so they will be installed where Pandoc expects them. This is hard to test!
Readme.md view
@@ -1,4 +1,4 @@-# knit-haskell v0.6.0.0+# knit-haskell v0.7.0.0 [![Build Status][travis-badge]][travis] [![Hackage][hackage-badge]][hackage]@@ -57,6 +57,10 @@ can be found in the [polysemy-zoo](https://github.com/isovector/polysemy-zoo). * Pandoc templates are included for HTML output. See the examples for how to access them or specify others.+* If you use knit-haskell via an installed executable, it will find the templates that +cabal installs. But if you use from a local build directory and use "cabal new-" or "cabal v2-"+style commands, you will need to run the executable via some "cabal v2-" command as well, e.g.,+"cabal v2-run" otherwise the templates--installed in the nix-style-build store--won't be found. * Though you can theoretically output to any format Pandoc can write--and it would be great to add some output formats!--some features only work with some output formats.
data/knit-haskell-templates/mindoc-pandoc-KH.html view
@@ -28,9 +28,9 @@ <!-- MathJax --> <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script> <!-- Vega and Vega Embed -->-<script src="https://cdn.jsdelivr.net/npm/vega@4.4.0"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc11"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.28.0"></script>+<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-lite@3"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-embed@4"></script> <!-- Extra styles --> <style>
data/knit-haskell-templates/pandoc-adaptive-bootstrap-KH.html view
@@ -24,9 +24,9 @@ <!-- MathJax --> <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script> <!-- Vega and Vega Embed -->-<script src="https://cdn.jsdelivr.net/npm/vega@4.4.0"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc11"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.28.0"></script> +<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-lite@3"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-embed@4"></script> <script src="script.js"></script>
data/knit-haskell-templates/pandoc-bootstrap-KH.html view
@@ -32,9 +32,9 @@ <!-- MathJax --> <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script> <!-- Vega and Vega Embed -->-<script src="https://cdn.jsdelivr.net/npm/vega@4.4.0"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc11"></script>-<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.28.0"></script>+<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-lite@3"></script>+<script src="https://cdn.jsdelivr.net/npm/vega-embed@4"></script> </head> <body> $if(title)$
examples/SimpleExample.hs view
@@ -24,7 +24,7 @@ main :: IO () main = do- let template = K.FromIncludedTemplateDir "mindoc-pandoc-KH.html"+ let template = K.DefaultTemplate --K.FromIncludedTemplateDir "mindoc-pandoc-KH.html" pandocWriterConfig <- K.mkPandocWriterConfig template templateVars K.mindocOptionsF
knit-haskell.cabal view
@@ -1,200 +1,201 @@-cabal-version: 2.4+cabal-version: 1.12 -name: knit-haskell-version: 0.6.0.1-synopsis: a minimal Rmarkdown sort-of-thing for haskell, by way of Pandoc-description: knit-haskell is a beginning attempt at bringing some of the benefits of- Rmarkdown to Haskell.- It includes an effects stack- (using <https://github.com/isovector/polysemy#readme polysemy> rather than mtl)- which includes logging, - a simplified interface to Pandoc and various writer-like effects to- intersperse document building with regular code.- Various helper functions are provided to simplify common operations,- making it especially straightforward to build- an HTML document from bits of markdown,- latex and <http://hackage.haskell.org/package/lucid Lucid>- or <http://hackage.haskell.org/package/blaze-html Blaze> html.- Support is also included for including- <http://hackage.haskell.org/package/hvega hvega> visualizations- and diagrams from the <https://archives.haskell.org/projects.haskell.org/diagrams/ diagrams>- package. - More information is available in the <https://github.com/adamConnerSax/knit-haskell/blob/master/Readme.md readme>.-bug-reports: https://github.com/adamConnerSax/knit-haskell/issues-license: BSD-3-Clause-license-file: LICENSE-author: Adam Conner-Sax-maintainer: adam_conner_sax@yahoo.com-copyright: 2019 Adam Conner-Sax-category: Text-extra-source-files: ChangeLog.md, Readme.md-data-dir: data-data-files:- knit-haskell-templates/*.html- knit-haskell-css/*.css- pandoc-data/data/templates/*.html4- pandoc-data/data/templates/*.html5- pandoc-data/data/templates/default.latex- pandoc-data/data/templates/default.markdown- pandoc-data/data/templates/default.commonmark- pandoc-data/data/templates/default.haddock+-- This file has been generated from package.yaml by hpack version 0.31.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: fc512e9236fe676c2be3010fe2354011663fe3c2e4c1cd9703f1f0c0bf9194e2 -Build-type: Simple+name: knit-haskell+version: 0.7.0.0+synopsis: a minimal Rmarkdown sort-of-thing for haskell, by way of Pandoc+description: knit-haskell is a beginning attempt at bringing some of the benefits of Rmarkdown to Haskell. It includes an effects stack (using <https://github.com/isovector/polysemy#readme polysemy> rather than mtl) which includes logging, a simplified interface to Pandoc and various writer-like effects to intersperse document building with regular code. Various helper functions are provided to simplify common operations, making it especially straightforward to build an HTML document from bits of markdown, latex and <http://hackage.haskell.org/package/lucid Lucid> or <http://hackage.haskell.org/package/blaze-html Blaze> html. Support is also included for including <http://hackage.haskell.org/package/hvega hvega> visualizations and diagrams from the <https://archives.haskell.org/projects.haskell.org/diagrams/ diagrams> package. More information is available in the <https://github.com/adamConnerSax/knit-haskell/blob/master/Readme.md readme>.+bug-reports: https://github.com/adamConnerSax/knit-haskell/issues+license: BSD3+license-file: LICENSE+author: Adam Conner-Sax+maintainer: adam_conner_sax@yahoo.com+copyright: 2019 Adam Conner-Sax+category: Text+extra-source-files:+ ChangeLog.md+ Readme.md+data-dir: data+data-files:+ knit-haskell-templates/mindoc-pandoc-KH.html+ knit-haskell-templates/pandoc-adaptive-bootstrap-KH.html+ knit-haskell-templates/pandoc-bootstrap-KH.html+ knit-haskell-css/pandoc-bootstrap.css+ pandoc-data/data/templates/default.html4+ pandoc-data/data/templates/default.html5+ pandoc-data/data/templates/default.latex+ pandoc-data/data/templates/default.markdown+ pandoc-data/data/templates/default.commonmark+ pandoc-data/data/templates/default.haddock+build-type: Simple+homepage: https://github.com/adamConnerSax/knit-haskell#readme source-repository head- Type: git- Location: https://github.com/adamConnerSax/knit-haskell+ type: git+ location: https://github.com/adamConnerSax/knit-haskell - library- ghc-options: -Wall -fno-warn-unused-top-binds -funbox-strict-fields- ghc-options: -fplugin=Polysemy.Plugin--- ghc-options: -fdefer-type-errors -fno-warn-deferred-type-errors--- when generating haddocks, comment out the plugin and uncomment the one above- exposed-modules: Knit.Effect.Logger- , Knit.Effect.Docs- , Knit.Effect.Html- , Knit.Effect.PandocMonad- , Knit.Effect.Pandoc- , Knit.Effect.UnusedId- , Knit.Report- , Knit.Report.Input.Table.Colonnade- , Knit.Report.Input.Html- , Knit.Report.Input.Html.Lucid- , Knit.Report.Input.Html.Blaze- , Knit.Report.Input.Latex- , Knit.Report.Input.MarkDown.PandocMarkDown- , Knit.Report.Input.Visualization.Hvega- , Knit.Report.Input.Visualization.Diagrams- , Knit.Report.Output- , Knit.Report.Output.Html- , Knit.Report.Other.Lucid- , Knit.Report.Other.Blaze- other-modules: Paths_knit_haskell- autogen-modules: Paths_knit_haskell -- build-depends: aeson-pretty >= 0.8.7 && < 0.9,- base >= 4.12.0 && < 4.13,- base64-bytestring >= 1.0.0.2 && < 1.1.0.0,- blaze-colonnade >= 1.2.2 && < 1.3.0.0,- bytestring >= 0.10.8 && < 0.11,- case-insensitive >= 1.2.0.11 && < 1.3.0.0,- colonnade >= 1.1 && < 1.3,- containers >= 0.5.0 && < 0.7,- constraints >= 0.10 && < 0.12,- directory >= 1.3.3.0 && < 1.4.0.0,- diagrams-lib >= 1.4 && < 1.5.0.0,- diagrams-svg >= 1.4.1 && < 1.5.0.0,- Glob >= 0.10.0 && < 0.11.0,- http-client >= 0.6.4 && < 0.7.0,- http-client-tls >= 0.3.5.3 && < 0.4.0.0,- http-types >= 0.12.3 && < 0.13.0,- network >= 2.8.0.0 && < 3.2.0.0,- network-uri >= 2.6.1.0 && < 2.7.0.0,- text >= 1.2.3 && < 1.3,- time >= 1.8.0 && < 2.0.0,- random >= 1.1 && < 1.2,- blaze-html >= 0.9.1 && < 0.10,- hvega >= 0.1.0 && <= 0.2.0.0,- logging-effect >= 1.3.3 && < 1.4,- mtl >= 2.2.2 && < 2.3,- polysemy >= 0.3.0.0 && < 0.5.0.0,- polysemy-plugin >= 0.2.0.0 && < 0.3.0.0,- polysemy-zoo >= 0.3.0.0 && < 0.4.0,- prettyprinter >= 1.2.1 && < 1.4,- lucid >= 2.9.11 && < 2.10,- pandoc >= 2.7.2 && < 2.8,- random-fu >= 0.2.7 && < 0.3,- random-source >= 0.3.0 && < 0.4,- svg-builder >= 0.1.1 && < 0.2-- hs-source-dirs: src- default-language: Haskell2010---test-suite SimpleExample- type: exitcode-stdio-1.0- main-is: SimpleExample.hs- hs-source-dirs: examples- ghc-options: -fplugin=Polysemy.Plugin- build-depends: base,- blaze-html,- containers,- here >= 1.2.10 && < 1.3.0,- hvega, - knit-haskell -any,- plots >= 0.1.1.0 && <= 0.2,- polysemy,- polysemy-plugin,- text - default-language: Haskell2010+ ghc-options: -Wall -fno-warn-unused-top-binds -funbox-strict-fields -fplugin=Polysemy.Plugin+ exposed-modules:+ Knit.Effect.Logger+ Knit.Effect.Docs+ Knit.Effect.Html+ Knit.Effect.PandocMonad+ Knit.Effect.Pandoc+ Knit.Effect.UnusedId+ Knit.Report+ Knit.Report.Input.Table.Colonnade+ Knit.Report.Input.Html+ Knit.Report.Input.Html.Lucid+ Knit.Report.Input.Html.Blaze+ Knit.Report.Input.Latex+ Knit.Report.Input.MarkDown.PandocMarkDown+ Knit.Report.Input.Visualization.Hvega+ Knit.Report.Input.Visualization.Diagrams+ Knit.Report.Output+ Knit.Report.Output.Html+ Knit.Report.Other.Lucid+ Knit.Report.Other.Blaze+ other-modules:+ Paths_knit_haskell+ build-depends:+ Glob >=0.10.0 && <0.11.0+ , aeson-pretty >=0.8.7 && <0.9+ , base >=4.12.0 && <4.13+ , base64-bytestring >=1.0.0.2 && <1.1.0.0+ , blaze-colonnade >=1.2.2 && <1.3.0.0+ , blaze-html >=0.9.1 && <0.10+ , bytestring >=0.10.8 && <0.11+ , case-insensitive >=1.2.0.11 && <1.3.0.0+ , colonnade >=1.1 && <1.3+ , constraints >=0.10 && <0.12+ , containers >=0.5.0 && <0.7+ , diagrams-lib >=1.4 && <1.5.0.0+ , diagrams-svg >=1.4.1 && <1.5.0.0+ , directory >=1.3.3.0 && <1.4.0.0+ , http-client >=0.6.4 && <0.7.0+ , http-client-tls >=0.3.5.3 && <0.4.0.0+ , http-types >=0.12.3 && <0.13.0+ , hvega >=0.2.0 && <=0.5+ , logging-effect >=1.3.3 && <1.4+ , lucid >=2.9.11 && <2.10+ , mtl >=2.2.2 && <2.3+ , network >=2.8.0.0 && <3.2.0.0+ , network-uri >=2.6.1.0 && <2.7.0.0+ , pandoc >=2.7.2 && <2.8+ , polysemy >=1.0.0.0 && <1.3+ , polysemy-plugin >=0.2.0.0 && <0.3.0.0+ , polysemy-zoo >=0.6.0 && <0.7+ , prettyprinter >=1.2.1 && <1.4+ , random >=1.1 && <1.2+ , random-fu >=0.2.7 && <0.3+ , random-source >=0.3.0 && <0.4+ , svg-builder >=0.1.1 && <0.2+ , text >=1.2.3 && <1.3+ , time >=1.8.0 && <2.0.0+ hs-source-dirs:+ src+ default-language: Haskell2010 test-suite ErrorExample- type: exitcode-stdio-1.0- main-is: ErrorExample.hs- hs-source-dirs: examples- ghc-options: -fplugin=Polysemy.Plugin- build-depends: base,- blaze-html,- containers,- here >= 1.2.10 && < 1.3.0,- hvega, - knit-haskell -any,- polysemy,- polysemy-plugin, - text - default-language: Haskell2010--test-suite MultiDocExample- type: exitcode-stdio-1.0- main-is: MultiDocExample.hs- hs-source-dirs: examples- ghc-options: -fplugin=Polysemy.Plugin- build-depends: base,- blaze-html,- containers,- here >= 1.2.10 && < 1.3.0,- hvega, - knit-haskell -any,- polysemy,- polysemy-plugin, - text - default-language: Haskell2010+ type: exitcode-stdio-1.0+ main-is: ErrorExample.hs+ hs-source-dirs:+ examples+ ghc-options: -fplugin=Polysemy.Plugin+ build-depends:+ base+ , blaze-html+ , containers+ , here >=1.2.10 && <1.3.0+ , hvega+ , knit-haskell+ , polysemy+ , polysemy-plugin+ , text+ default-language: Haskell2010 test-suite MtlExample- type: exitcode-stdio-1.0- main-is: MtlExample.hs- hs-source-dirs: examples- ghc-options: -fplugin=Polysemy.Plugin- build-depends: base,- blaze-html,- containers,- here,- hvega,- knit-haskell -any,- mtl,- polysemy,- polysemy-plugin, - text- default-language: Haskell2010+ type: exitcode-stdio-1.0+ main-is: MtlExample.hs+ hs-source-dirs:+ examples+ ghc-options: -fplugin=Polysemy.Plugin+ build-depends:+ base+ , blaze-html+ , containers+ , here+ , hvega+ , knit-haskell+ , mtl+ , polysemy+ , polysemy-plugin+ , text+ default-language: Haskell2010 +test-suite MultiDocExample+ type: exitcode-stdio-1.0+ main-is: MultiDocExample.hs+ hs-source-dirs:+ examples+ ghc-options: -fplugin=Polysemy.Plugin+ build-depends:+ base+ , blaze-html+ , containers+ , here >=1.2.10 && <1.3.0+ , hvega+ , knit-haskell+ , polysemy+ , polysemy-plugin+ , text+ default-language: Haskell2010+ test-suite RandomExample- type: exitcode-stdio-1.0- main-is: RandomExample.hs- hs-source-dirs: examples- ghc-options: -fplugin=Polysemy.Plugin - build-depends: base,- blaze-html,- colonnade,- containers,- here,- hvega,- knit-haskell -any,- mtl,- polysemy,- polysemy-plugin,- polysemy-RandomFu >= 0.2.0.0,- random-fu,- random-source,- text- default-language: Haskell2010 + type: exitcode-stdio-1.0+ main-is: RandomExample.hs+ hs-source-dirs:+ examples+ ghc-options: -fplugin=Polysemy.Plugin+ build-depends:+ base+ , blaze-html+ , colonnade >=1.2.0.2+ , containers+ , here >=1.2.10 && <1.3.0+ , hvega+ , knit-haskell+ , mtl >=2.2.2+ , plots >=0.1.1.0 && <=0.2+ , polysemy+ , polysemy-RandomFu >=0.4.0 && <0.5+ , polysemy-plugin+ , random-fu >=0.2.7.0+ , random-source >=0.3.0.6+ , text+ default-language: Haskell2010++test-suite SimpleExample+ type: exitcode-stdio-1.0+ main-is: SimpleExample.hs+ hs-source-dirs:+ examples+ ghc-options: -fplugin=Polysemy.Plugin+ build-depends:+ base+ , blaze-html+ , containers+ , here+ , hvega+ , knit-haskell+ , plots+ , polysemy+ , polysemy-plugin+ , text+ default-language: Haskell2010
src/Knit/Effect/PandocMonad.hs view
@@ -24,9 +24,10 @@ Stability : experimental Polysemy PandocMonad effect.-Allows a polysemy monad to handle functions+Allows a polysemy monad to handle actions with a PandocMonad contraint via polysemy effects and IO.+Has an "absorber" to convert functions with a @PandocMonad@ constraint. -} module Knit.Effect.PandocMonad (@@ -273,13 +274,13 @@ trace = Action . trace_ (P.reflect $ P.Proxy @s') -- | Constraint helper for using this set of effects in IO.-type PandocEffectsIO effs = (PandocEffects effs, P.Member (P.Lift IO) effs)+type PandocEffectsIO effs = (PandocEffects effs, P.Member (P.Embed IO) effs) -- | Interpret the Pandoc effect using @IO@, @Knit.Effect.Logger@ and @PolySemy.Error PandocError@ interpretInIO :: forall effs a . ( P.Member (Log.Logger Log.LogEntry) effs- , P.Member (P.Lift IO) effs+ , P.Member (P.Embed IO) effs , P.Member (P.Error PA.PandocError) effs ) => P.Sem (Pandoc ': effs) a@@ -316,31 +317,31 @@ interpretInPandocMonad :: forall m effs a . ( PA.PandocMonad m- , P.Member (P.Lift m) effs+ , P.Member (P.Embed m) effs , P.Member (Log.Logger Log.LogEntry) effs ) => P.Sem (Pandoc ': effs) a -> P.Sem effs a interpretInPandocMonad = P.interpret (\case- LookupEnv s -> P.sendM @m $ PA.lookupEnv s- GetCurrentTime -> P.sendM @m $ PA.getCurrentTime- GetCurrentTimeZone -> P.sendM @m $ PA.getCurrentTimeZone- NewStdGen -> P.sendM @m $ PA.newStdGen- NewUniqueHash -> P.sendM @m $ PA.newUniqueHash- OpenURL s -> P.sendM @m $ PA.openURL s- ReadFileLazy fp -> P.sendM @m $ PA.readFileLazy fp- ReadFileStrict fp -> P.sendM @m $ PA.readFileStrict fp- Glob fp -> P.sendM @m $ PA.glob fp- FileExists fp -> P.sendM @m $ PA.fileExists fp- GetDataFileName fp -> P.sendM @m $ PA.getDataFileName fp- GetModificationTime fp -> P.sendM @m $ PA.getModificationTime fp- GetCommonState -> P.sendM @m $ PA.getCommonState- PutCommonState cs -> P.sendM @m $ PA.putCommonState cs- GetsCommonState f -> P.sendM @m $ PA.getsCommonState f- ModifyCommonState f -> P.sendM @m $ PA.modifyCommonState f+ LookupEnv s -> P.embed @m $ PA.lookupEnv s+ GetCurrentTime -> P.embed @m $ PA.getCurrentTime+ GetCurrentTimeZone -> P.embed @m $ PA.getCurrentTimeZone+ NewStdGen -> P.embed @m $ PA.newStdGen+ NewUniqueHash -> P.embed @m $ PA.newUniqueHash+ OpenURL s -> P.embed @m $ PA.openURL s+ ReadFileLazy fp -> P.embed @m $ PA.readFileLazy fp+ ReadFileStrict fp -> P.embed @m $ PA.readFileStrict fp+ Glob fp -> P.embed @m $ PA.glob fp+ FileExists fp -> P.embed @m $ PA.fileExists fp+ GetDataFileName fp -> P.embed @m $ PA.getDataFileName fp+ GetModificationTime fp -> P.embed @m $ PA.getModificationTime fp+ GetCommonState -> P.embed @m $ PA.getCommonState+ PutCommonState cs -> P.embed @m $ PA.putCommonState cs+ GetsCommonState f -> P.embed @m $ PA.getsCommonState f+ ModifyCommonState f -> P.embed @m $ PA.modifyCommonState f LogOutput msg -> logPandocMessage msg- Trace s -> P.sendM @m $ PA.trace s+ Trace s -> P.embed @m $ PA.trace s ) -- | Run the Pandoc effects,@@ -350,7 +351,7 @@ :: [Log.LogSeverity] -> P.Sem '[Pandoc, Log.Logger Log.LogEntry, Log.PrefixLog, P.Error- PA.PandocError, P.Lift IO]+ PA.PandocError, P.Embed IO] a -> IO (Either PA.PandocError a) runIO lss =@@ -360,7 +361,7 @@ openURLWithState :: forall effs . ( P.Member (Log.Logger Log.LogEntry) effs- , P.Member (P.Lift IO) effs+ , P.Member (P.Embed IO) effs , P.Member (P.Error PA.PandocError) effs ) => PA.CommonState@@ -414,7 +415,7 @@ -- | Utility function to lift IO errors into Sem liftIOError- :: (P.Member (P.Error PA.PandocError) effs, P.Member (P.Lift IO) effs)+ :: (P.Member (P.Error PA.PandocError) effs, P.Member (P.Embed IO) effs) => (String -> IO a) -> String -> P.Sem effs a@@ -424,14 +425,12 @@ Left e -> P.throw $ PA.PandocIOError u e Right r -> return r --- this default is built into Pandoc. I could probably do something more useful here but maybe something depends on it??--- or maybe the actual version on each machine has a correct local version??--- TODO: Fix/Understand this-datadir :: IO FilePath-datadir = Paths.getDataDir--- "/home/builder/hackage-server/build-cache/tmp-install/share/x86_64-linux-ghc-8.6.3/pandoc-2.7.2"-+-- | adjust the directory the PandocMonad sees so that it will get+-- the right files when it falls back to default. Knit-haskell installs+-- differently than pandoc does so that it can have its own templates as+-- well. getDataFileName' :: FilePath -> IO FilePath getDataFileName' fp = do- dir <- E.catch @E.IOException (IO.getEnv "pandoc_datadir") (\_ -> datadir)+ dir <- E.catch @E.IOException (IO.getEnv "pandoc_datadir")+ (\_ -> Paths.getDataDir) return (dir ++ "/pandoc-data/" ++ fp)
src/Knit/Report.hs view
@@ -27,12 +27,10 @@ Notes: -1. The "Knit.Effect.RandomFu" effect is not imported since the names might clash with "Polysemy.Random".-Import either effect directly if you need it.-2. You can add logging from within document creation using 'logLE'.-3. The "Knit.Report.Input.MarkDown.PandocMarkDown" module is exported+1. You can add logging from within document creation using 'logLE'.+2. The "Knit.Report.Input.MarkDown.PandocMarkDown" module is exported so if you want to use a different markdown flavor you may need to hide "addMarkDown" when you import this module.-4. If you use any other effects in your polysemy stack (e.g., Random or RandomFu), you will need to interpret/run them before calling knitHtml/knitHtmls.+3. If you use any other effects in your polysemy stack (e.g., Random or RandomFu), you will need to interpret/run them before calling knitHtml/knitHtmls. -} module Knit.Report (@@ -72,7 +70,7 @@ import Polysemy ( Member , Sem- , Lift+ , Embed ) import Knit.Effect.Pandoc ( ToPandoc , Requirement(..)@@ -174,11 +172,11 @@ . KO.pandocWriterToBlazeDocument writeConfig -- | Constraints required to knit a document using effects from a base monad m.-type KnitBase m effs = (MonadIO m, P.Member (P.Lift m) effs)+type KnitBase m effs = (MonadIO m, P.Member (P.Embed m) effs) -- | lift an action in a base monad into a Polysemy monad. This is just a renaming for convenience.-liftKnit :: Member (Lift m) r => m a -> Sem r a-liftKnit = P.sendM+liftKnit :: Member (Embed m) r => m a -> Sem r a+liftKnit = P.embed -- | Throw an error with a specific message. This will emerge as a 'PandocSomeError' in order -- to avoid complicating the error type.@@ -187,8 +185,17 @@ knitError msg = PE.throw (PA.PandocSomeError $ "Knit User Error: " ++ T.unpack msg) --- | Constraint alias for the effects we need when calling Knit-type KnitEffects r = (KPM.PandocEffects r, P.Member KUI.UnusedId r)+-- | Constraint alias for the effects we need (and run)+-- when calling Knit.+-- Anything inside a call to Knit can use any of these effects.+-- Any other effects will need to be run before @knitHtml(s)@+type KnitEffects r = (KPM.PandocEffects r+ , P.Members [ KUI.UnusedId+ , KLog.Logger KLog.LogEntry+ , KLog.PrefixLog+ , PE.Error PA.PandocError+ , P.Embed IO] r+ ) -- | Constraint alias for the effects we need to knit one document type KnitOne r = (KnitEffects r, P.Member KP.ToPandoc r)@@ -197,13 +204,11 @@ type KnitMany r = (KnitEffects r, P.Member KP.Pandocs r) -- -- From here down is unexported. -- | The exact stack we are interpreting when we knit type KnitEffectStack m = '[KUI.UnusedId, KPM.Pandoc, KLog.Logger KLog.LogEntry, KLog.PrefixLog, PE.Error- PA.PandocError, P.Lift IO, P.Lift m]+ PA.PandocError, P.Embed IO, P.Embed m] -- | Add a Multi-doc writer to the front of the effect list type KnitEffectDocsStack m = (KP.Pandocs ': KnitEffectStack m) @@ -220,7 +225,7 @@ -> m (Either PA.PandocError a) consumeKnitEffectStack loggingPrefixM ls = P.runM- . PI.runIO @m -- interpret (Lift IO) using m+ . PI.embedToMonadIO @m -- interpret (Embed IO) using m . PE.runError . KLog.filteredLogEntriesToIO ls . KPM.interpretInIO -- PA.PandocIO