packages feed

HaTeX 3.22.3.2 → 3.22.4.0

raw patch · 15 files changed

+296/−356 lines, 15 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.LaTeX.Packages.BibLaTeX: applyDOIReferenceResolves :: (MonadIO m, LaTeXC (m ()), Semigroup (m ()), r ~ DOIReference) => (r -> m (Maybe T)) -> ReferenceQueryT r m () -> m (Map DOIReference T, m ())
+ Text.LaTeX.Packages.BibLaTeX: instance GHC.Show.Show Text.LaTeX.Packages.BibLaTeX.DOIReference

Files

CHANGELOG.md view
@@ -5,10 +5,18 @@ For a full list of changes, see the commit history of the git repository: -https://github.com/Daniel-Diaz/HaTeX/commits/master+https://gitlab.com/daniel-casanueva/haskell/HaTeX/-/commits/main  # Changelog by versions +## 3.22.4.0+* Define `(<>)` instead of `mappend`.+* Use `fmap` instead of `liftM`.+* New function: `applyDOIReferenceResolves`.+* Make parser test more lenient (it was commented due to issue #144).+* Metadata update.+* Unify files `ReleaseNotes` and `CHANGELOG.md`.+ ## From 3.22.3.1 to 3.22.3.2 * Relax transformers dependency upper bound from `< 0.6` to `< 0.7`. @@ -134,3 +142,85 @@ * Modified LaTeX Monoid instance to make monoid laws hold. * Some documentation improvements. * Added this CHANGELOG!++## 3.4++* Num instance for LaTeXT.+* New re-exports: liftIO.+* Relaxed transformers package dependency to: >= 0.2.2 && < 0.4+* Changed infix rule of (=:) and (/=:).+* More documentation notes.+* New functions: hfill, vfill.+* The internal representation of LaTeXT has changed to prevent+  a set of errors.+* Changes in Text.LaTeX.+* Several minor fixes.++## 3.3++* New functions 'protectString' and 'protectText'.+* New function 'rendertexM'.+* New environments: 'figure' and 'caption'.+* New example: simple.hs.+* Updated version of transfomers to 0.3.*.+* Trees implemented: datatype and Qtree package.+* Render instances for Integer and Double.+* New docs.+* Class system implemented. Monad modules dropped.++## 3.2.0.1++* This version only fix the patch that makes HaTeX compatible with GHC 7.4.++## 3.2++### Highlights:++* Parser implemented (New dependency on parsec).+* Greek alphabet added to AMSMath.+* New LaTeX package: graphicx.+* Function 'documentclass' changed.++### Other changes:++* Dependency changed from mtl to transformers.+* New commands: par, textwidth and linewidth.+* New environment: minipage.+* Compatibility with GHC 7.4 (with CPP extension).+* Function 'lift' is now re-exported in Text.LaTeX.Base.Writer module.+* New function 'renderChars' in the Render module.+* ReadMe edited, now with ToDo list.++## 3.1.1++* Dependency relaxed from 'mtl == 2.*' to 'transformers == 0.2.*'.++## 3.1.0++### Highlights:++* Added warnings (See Text.LaTeX.Base.Warnings).+* Added an "Examples" directory.+* Num instance for LaTeX and LaTeXT.+* New package implemented "AMSThm" (See Text.LaTeX.Packages.AMSThm).++### Changes by modules:++Base modules:++* Text.LaTeX.Base.Syntax: Added Eq instance to LaTeX and TeXArg.+* Text.LaTeX.Base.Writer: Added MonadTrans instance to LaTeXT.+    New functions: execLaTeXTWarn, liftFun, liftOp.+* Text.LaTeX.Base.Types: Added Eq instance to Label.+* Text.LaTeX.Base: Added Num instance to LaTeX.+* Text.LaTeX.Base.Monad: Added Num instance to LaTeXT.+* Text.LaTeX.Base.Commands: New function: between.++Package modules:++* Text.LaTeX.Packages.AMSMath: New symbols: (=:) , (/=:) , forall+    , dagger, ddagger, in_ , ni, (<:) , (<=:), (>:) , (>=:)++## 3.0.0++* First release of the third version of HaTeX.
HaTeX.cabal view
@@ -1,149 +1,144 @@-Name: HaTeX
-Version: 3.22.3.2
-Author: Daniel Casanueva
-Category: LaTeX
-Build-type: Simple
-License: BSD3
-License-file: license
-Maintainer: Daniel Casanueva
-Bug-reports: https://github.com/Daniel-Diaz/HaTeX/issues
-homepage: https://github.com/Daniel-Diaz/HaTeX/blob/master/README.md
-Synopsis: The Haskell LaTeX library.
-Description: This library implements the LaTeX syntax and provides some useful abstractions.
-             .
-             Some of the things you can do with HaTeX are:
-             .
-             * Write LaTeX documents with all the advantages you already have in Haskell: recursion,
-               type system, high order functions, ...
-             .
-             * Create a LaTeX backend for your own program.
-             .
-             * Parse a LaTeX file and obtain its Abstract Syntax Tree (AST).
-             .
-             * Pretty-print Haskell values in LaTeX.
-             .
-             * Generate TikZ scripts (images!) easily.
-             .
-             Browse the @examples@ directory in the source distribution to see some simple examples.
-             It might help you to get started. The HaTeX User's Guide is available at
-             <https://github.com/Daniel-Diaz/hatex-guide/blob/master/README.md>.
-             .
-             If you prefer to write in LaTeX and all you want is to /program/ some parts of the document,
-             or if you already have the LaTeX document written and you just want to add some automatically
-             generated LaTeX code somewhere, check haskintex: <http://daniel-diaz.github.io/projects/haskintex>.
-             It allows you to embed Haskell in LaTeX. It also makes you easy to use HaTeX within a LaTeX document.
-Cabal-version: 1.18
-Extra-source-files:
-  ReleaseNotes
-  README.md
-  CHANGELOG.md
-  -- Examples
-  Examples/*.hs
-  -- Tests
-  parsertest/*.tex
-  parsertest/parsertest.hs
-Extra-doc-files:
-  -- TikZ
-  docfiles/tikz/*.png
-  -- Beamer
-  docfiles/beamers/*.png
-  -- Others
-  docfiles/others/*.png
-
-Source-repository head
-  type: git
-  location: git://github.com/Daniel-Diaz/HaTeX.git
-
-Library
-  Default-language: Haskell2010
-  Build-depends: base == 4.*
-               , bytestring >= 0.9.2.1 && < 0.12
-               , text >= 0.11.2.3 && < 2.1
-               , transformers >= 0.2.2 && < 0.7
-               , containers >= 0.4.2.1 && < 0.7
-               , hashable >= 1.2 && < 1.5
-               , bibtex >= 0.1 && < 0.2
-               , matrix
-                 -- Testing
-               , QuickCheck
-                 -- Parsing
-               , parsec >= 3.1.6
-                 -- Pretty-printing
-               , prettyprinter
-  if impl(ghc < 7.6)
-    build-depends: ghc-prim
-  if impl(ghc < 8.0)
-    build-depends: semigroups
-  Exposed-modules:
-    Text.LaTeX
-      -- Base (Core of the library)
-      Text.LaTeX.Base
-        Text.LaTeX.Base.Class
-        Text.LaTeX.Base.Commands
-        Text.LaTeX.Base.Math
-        Text.LaTeX.Base.Parser
-        Text.LaTeX.Base.Pretty
-        Text.LaTeX.Base.Render
-        Text.LaTeX.Base.Syntax
-        Text.LaTeX.Base.Texy
-        Text.LaTeX.Base.Types
-        Text.LaTeX.Base.Writer
-        Text.LaTeX.Base.Warnings
-        -- Packages
-        Text.LaTeX.Packages.Acronym
-        Text.LaTeX.Packages.AMSFonts
-        Text.LaTeX.Packages.AMSMath
-        Text.LaTeX.Packages.AMSSymb
-        Text.LaTeX.Packages.AMSThm
-        Text.LaTeX.Packages.Babel
-        Text.LaTeX.Packages.Beamer
-        Text.LaTeX.Packages.BibLaTeX
-        Text.LaTeX.Packages.Bigstrut
-        Text.LaTeX.Packages.Color
-        Text.LaTeX.Packages.Fancyhdr
-        Text.LaTeX.Packages.Fontenc
-        Text.LaTeX.Packages.Geometry
-        Text.LaTeX.Packages.Graphicx
-        Text.LaTeX.Packages.Hyperref
-        Text.LaTeX.Packages.LongTable
-        Text.LaTeX.Packages.Lscape
-        Text.LaTeX.Packages.LTableX
-        Text.LaTeX.Packages.Inputenc
-        Text.LaTeX.Packages.Multirow
-        Text.LaTeX.Packages.QRCode
-        Text.LaTeX.Packages.Relsize
-        Text.LaTeX.Packages.TabularX
-        -- Trees
-        Text.LaTeX.Packages.Trees
-          Text.LaTeX.Packages.Trees.Qtree
-        -- TikZ
-        Text.LaTeX.Packages.TikZ
-          Text.LaTeX.Packages.TikZ.PathBuilder
-          Text.LaTeX.Packages.TikZ.Simple
-          Text.LaTeX.Packages.TikZ.Syntax
-  Other-modules: Paths_HaTeX
-  Default-extensions: OverloadedStrings, TypeFamilies
-  Other-extensions: CPP
-  ghc-options: -Wall -fno-warn-orphans
-
-Test-Suite hatex-test
-  Default-language: Haskell2010
-  type: exitcode-stdio-1.0
-  hs-source-dirs: test
-  main-is: Main.hs
-  build-depends: base == 4.*
-               , HaTeX
-               , tasty
-               , QuickCheck
-               , tasty-quickcheck
-               , parsec
-  ghc-options: -Wall -fno-warn-orphans
-Test-Suite parser-tests
-  Default-language: Haskell2010
-  type: exitcode-stdio-1.0
-  hs-source-dirs: parsertest
-  main-is: parsertest.hs
-  build-depends: base == 4.*
-               , HaTeX
-               , text
-  ghc-options: -Wall
+Name: HaTeX+Version: 3.22.4.0+Category: LaTeX+Build-type: Simple+License: BSD3+License-file: license+Author: Daniel Casanueva (daniel.casanueva `at` proton.me)+Maintainer: Daniel Casanueva (daniel.casanueva `at` proton.me)+homepage: https://gitlab.com/daniel-casanueva/haskell/HaTeX+Bug-reports: https://gitlab.com/daniel-casanueva/haskell/HaTeX/-/issues+Synopsis: The Haskell LaTeX library.+Description: This library implements the LaTeX syntax and provides some useful abstractions.+             .+             Some of the things you can do with HaTeX are:+             .+             * Write LaTeX documents with all the advantages you already have in Haskell: recursion,+               type system, high order functions, ...+             .+             * Create a LaTeX backend for your own program.+             .+             * Parse a LaTeX file and obtain its Abstract Syntax Tree (AST).+             .+             * Pretty-print Haskell values in LaTeX.+             .+             * Generate TikZ scripts (images!) easily.+             .+             Browse the @examples@ directory in the source distribution to see some simple examples.+             It might help you to get started.+             .+             If you prefer to write in LaTeX and all you want is to /program/ some parts of the document,+             or if you already have the LaTeX document written and you just want to add some automatically+             generated LaTeX code somewhere, check haskintex: <https://daniel-casanueva.gitlab.io/haskell/haskintex>.+             It allows you to embed Haskell in LaTeX. It also makes it easy to use HaTeX within a LaTeX document.+Cabal-version: 1.18+Extra-source-files:+  -- Examples+  Examples/*.hs+  -- Tests+  parsertest/*.tex+  parsertest/parsertest.hs+Extra-doc-files:+  README.md+  CHANGELOG.md+  -- TikZ+  docfiles/tikz/*.png+  -- Beamer+  docfiles/beamers/*.png+  -- Others+  docfiles/others/*.png++Library+  Default-language: Haskell2010+  Build-depends: base == 4.*+               , bytestring >= 0.9.2.1 && < 0.12+               , text >= 0.11.2.3 && < 2.1+               , transformers >= 0.2.2 && < 0.7+               , containers >= 0.4.2.1 && < 0.7+               , hashable >= 1.2 && < 1.5+               , bibtex >= 0.1 && < 0.2+               , matrix+                 -- Testing+               , QuickCheck+                 -- Parsing+               , parsec >= 3.1.6+                 -- Pretty-printing+               , prettyprinter+  if impl(ghc < 7.6)+    build-depends: ghc-prim+  if impl(ghc < 8.0)+    build-depends: semigroups+  Exposed-modules:+    Text.LaTeX+      -- Base (Core of the library)+      Text.LaTeX.Base+        Text.LaTeX.Base.Class+        Text.LaTeX.Base.Commands+        Text.LaTeX.Base.Math+        Text.LaTeX.Base.Parser+        Text.LaTeX.Base.Pretty+        Text.LaTeX.Base.Render+        Text.LaTeX.Base.Syntax+        Text.LaTeX.Base.Texy+        Text.LaTeX.Base.Types+        Text.LaTeX.Base.Writer+        Text.LaTeX.Base.Warnings+        -- Packages+        Text.LaTeX.Packages.Acronym+        Text.LaTeX.Packages.AMSFonts+        Text.LaTeX.Packages.AMSMath+        Text.LaTeX.Packages.AMSSymb+        Text.LaTeX.Packages.AMSThm+        Text.LaTeX.Packages.Babel+        Text.LaTeX.Packages.Beamer+        Text.LaTeX.Packages.BibLaTeX+        Text.LaTeX.Packages.Bigstrut+        Text.LaTeX.Packages.Color+        Text.LaTeX.Packages.Fancyhdr+        Text.LaTeX.Packages.Fontenc+        Text.LaTeX.Packages.Geometry+        Text.LaTeX.Packages.Graphicx+        Text.LaTeX.Packages.Hyperref+        Text.LaTeX.Packages.LongTable+        Text.LaTeX.Packages.Lscape+        Text.LaTeX.Packages.LTableX+        Text.LaTeX.Packages.Inputenc+        Text.LaTeX.Packages.Multirow+        Text.LaTeX.Packages.QRCode+        Text.LaTeX.Packages.Relsize+        Text.LaTeX.Packages.TabularX+        -- Trees+        Text.LaTeX.Packages.Trees+          Text.LaTeX.Packages.Trees.Qtree+        -- TikZ+        Text.LaTeX.Packages.TikZ+          Text.LaTeX.Packages.TikZ.PathBuilder+          Text.LaTeX.Packages.TikZ.Simple+          Text.LaTeX.Packages.TikZ.Syntax+  Other-modules: Paths_HaTeX+  Default-extensions: OverloadedStrings, TypeFamilies, TypeOperators+  Other-extensions: CPP+  ghc-options: -Wall -fno-warn-orphans++Test-Suite hatex-test+  Default-language: Haskell2010+  type: exitcode-stdio-1.0+  hs-source-dirs: test+  main-is: Main.hs+  build-depends: base == 4.*+               , HaTeX+               , tasty+               , QuickCheck+               , tasty-quickcheck+               , parsec+  ghc-options: -Wall -fno-warn-orphans++Test-Suite parser-tests+  Default-language: Haskell2010+  type: exitcode-stdio-1.0+  hs-source-dirs: parsertest+  main-is: parsertest.hs+  build-depends: base == 4.*+               , HaTeX+               , text+  ghc-options: -Wall
README.md view
@@ -3,81 +3,21 @@  HaTeX is a Haskell library that implements the *LaTeX syntax*, plus some abstractions on top. -Check a list of usage examples in the [Examples](https://github.com/Daniel-Diaz/HaTeX/tree/master/Examples) directory+Check a list of usage examples in the [Examples](https://gitlab.com/daniel-casanueva/haskell/HaTeX/-/tree/main/Examples) directory of the repository in GitHub.-A good starting point is [simple.hs](https://github.com/Daniel-Diaz/HaTeX/blob/master/Examples/simple.hs).-Run any example script executing the ``main`` function.--## Installation notes--To install `HaTeX`, use [cabal-install](http://hackage.haskell.org/package/cabal-install)-or [stack](http://docs.haskellstack.org/en/stable/README).--To install with cabal, run:--    $ cabal update-    $ cabal install HaTeX--This will download and install the latest official release (recommended).-If you want to try a newer version, use _git_ to clone the code contained-in this repository.--    $ git clone https://github.com/Daniel-Diaz/HaTeX.git-    $ cd HaTeX-    $ cabal install--However, this is not recommended as it may include some bugs or oddities due to in-development features.-Note that this package follows the [_Package Versioning Policy_](http://www.haskell.org/haskellwiki/Package_versioning_policy),-so it is unlikely to suffer from API breakages if you follow it too when importing the library (assuming-you are using the version in Hackage).--## Current HaTeX versions--[![HaTeX on Hackage](https://img.shields.io/hackage/v/HaTeX.svg)](https://hackage.haskell.org/package/HaTeX)--[![HaTeX on Stackage](http://stackage.org/package/HaTeX/badge/lts)](http://stackage.org/lts/package/HaTeX)--[![HaTeX on Stackage Nightly](http://stackage.org/package/HaTeX/badge/nightly)](http://stackage.org/nightly/package/HaTeX)--## HaTeX User's Guide--The HaTeX User's Guide lives [here](https://github.com/Daniel-Diaz/hatex-guide)... and is also done in Haskell!-It is free source and anybody can contribute to it. Doing so, you will help current and future users!--A downloadable version (not necessarily the latest version, but most likely)-can be found [here](http://daniel-diaz.github.com/projects/hatex/hatex-guide.pdf).-To be sure that you are reading the last version, go to the github repository of the guide and follow instructions-to build it. It is fairly easy.--Please note that the user's guide needs to be updated (contributions are more than welcome!).--## Community and Contributions--There are many ways to get involved in the HaTeX project. Use the most comfortable way for you.+A good starting point is [simple.hs](https://gitlab.com/daniel-casanueva/haskell/HaTeX/-/blob/main/Examples/simple.hs?ref_type=heads).+Run any example script executing the `main` function. -* Fork the [GitHub repository](https://github.com/Daniel-Diaz/HaTeX) and make your own contributions.-* Report bugs or make suggestions opening a ticket in the [Issue Tracker](https://github.com/Daniel-Diaz/HaTeX/issues).-* Help us to improve and extend our [hatex-guide](https://github.com/Daniel-Diaz/hatex-guide).+## How to contribute -## TODO list+There are the options for potential contributors: -* Add more examples.-* Add more documentation.-* BibTeX support.+* Fork the [GitLab repository](https://gitlab.com/daniel-casanueva/haskell/HaTeX) and open a merge request.+* Report bugs or make suggestions opening a ticket in the [Issue Tracker](https://gitlab.com/daniel-casanueva/haskell/HaTeX/-/issues).  ## Related projects -* [haskintex](http://daniel-diaz.github.io/projects/haskintex): Tool to use Haskell (and, additionaly, the HaTeX library)+* [haskintex](https://daniel-casanueva.gitlab.io/haskell/haskintex): Tool to use Haskell (and, additionaly, the HaTeX library) within a LaTeX file. * [TeX-my-math](https://github.com/leftaroundabout/Symbolic-math-HaTeX): Experimental library to ease the production of mathematical expressions using HaTeX.--## Travis automatic build--For every code push to the GitHub repository, an automatic build checks that the library compiles with several-versions of GHC (check [.travis.yml](https://github.com/Daniel-Diaz/HaTeX/blob/master/.travis.yml) for the complete list of versions)-and that all tests pass. This label indicates the result of the last automatic build.--[![Build Status](https://travis-ci.org/Daniel-Diaz/HaTeX.png?branch=master)](https://travis-ci.org/Daniel-Diaz/HaTeX)--Currently, automatic builds are only running under Linux.
− ReleaseNotes
@@ -1,91 +0,0 @@-HaTeX Release Notes--- From version 3.0.0-->>> 3.4--- Num instance for LaTeXT.-- New re-exports: liftIO.-- Relaxed transformers package dependency to: >= 0.2.2 && < 0.4-- Changed infix rule of (=:) and (/=:).-- More documentation notes.-- New functions: hfill, vfill.-- The internal representation of LaTeXT has changed to prevent-  a set of errors.-- Changes in Text.LaTeX.-- Several minor fixes.-->>> 3.3--- New functions 'protectString' and 'protectText'.-- New function 'rendertexM'.-- New environments: 'figure' and 'caption'.-- New example: simple.hs.-- Updated version of transfomers to 0.3.*.-- Trees implemented: datatype and Qtree package.-- Render instances for Integer and Double.-- New docs.-- Class system implemented. Monad modules dropped.-->>> 3.2.0.1--- This version only fix the patch that makes HaTeX compatible with GHC 7.4.-->>> 3.2--Highlights:--+ Parser implemented (New dependency on parsec).-+ Greek alphabet added to AMSMath.-+ New LaTeX package: graphicx.-+ Function 'documentclass' changed.--Other changes:--- Dependency changed from mtl to transformers.-- New commands: par, textwidth and linewidth.-- New environment: minipage.-- Compatibility with GHC 7.4 (with CPP extension).-- Function 'lift' is now re-exported in Text.LaTeX.Base.Writer module.-- New function 'renderChars' in the Render module.-- ReadMe edited, now with ToDo list.-->>> 3.1.1--- Dependency relaxed from 'mtl == 2.*' to 'transformers == 0.2.*'.-->>> 3.1.0--Highlights:--+ Added warnings (See Text.LaTeX.Base.Warnings).-+ Added an "Examples" directory.-+ Num instance for LaTeX and LaTeXT.-+ New package implemented "AMSThm" (See Text.LaTeX.Packages.AMSThm).--Changes by modules:--** Base modules-* Text.LaTeX.Base.Syntax:--- Added Eq instance to LaTeX and TeXArg.-* Text.LaTeX.Base.Writer:--- Added MonadTrans instance to LaTeXT.--- New functions: execLaTeXTWarn, liftFun, liftOp.-* Text.LaTeX.Base.Types:--- Added Eq instance to Label.-* Text.LaTeX.Base:--- Added Num instance to LaTeX.-* Text.LaTeX.Base.Monad:--- Added Num instance to LaTeXT.-* Text.LaTeX.Base.Commands:--- New function: between.--** Package modules:-* Text.LaTeX.Packages.AMSMath--- New symbols: (=:) , (/=:) , forall-              , dagger, ddagger, in_ , ni-              , (<:) , (<=:)-              , (>:) , (>=:)-->>> 3.0.0--* First release of the third version of HaTeX.
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
Text/LaTeX/Base/Class.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-name-shadowing #-}+{-# OPTIONS_GHC -Wno-name-shadowing #-}+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}  -- | Definition of the 'LaTeXC' class, used to combine the classic applicative and --   the latter monadic interfaces of /HaTeX 3/. The user can define new instances
Text/LaTeX/Base/Commands.hs view
@@ -1165,11 +1165,11 @@ -- | Print the HaTeX logo, beside the complete version number. hatex_version :: LaTeXC l => l hatex_version = hatex-             <> emph (textbf $ rendertex x)+             <> emph (textbf $ rendertex $ head v)              <> hspace (Ex $ negate 0.3)-             <> emph ("." <> fromString (intercalate "." $ fmap show xs))+             <> emph ("." <> fromString (intercalate "." $ fmap show $ tail v))  where-  (x:xs) = versionBranch version+  v = versionBranch version  caption :: LaTeXC l => l -> l caption = liftL $ \l -> TeXComm "caption" [FixArg l]
Text/LaTeX/Base/Math.hs view
@@ -1,6 +1,6 @@- {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP               #-}+{-# OPTIONS_GHC -Wno-orphans #-}  -- | This module contains the maths-specific part of "Text.LaTeX.Base.Commands", --  i.e. of the commands that are available in LaTeX out of the box without
Text/LaTeX/Base/Pretty.hs view
@@ -13,7 +13,7 @@  import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Render-import Data.Text.Prettyprint.Doc+import Prettyprinter   ( Doc, pretty   , backslash, line, softline, hardline   , braces, brackets@@ -23,7 +23,7 @@   , PageWidth (..)   , layoutSmart     )-import Data.Text.Prettyprint.Doc.Render.String (renderString)+import Prettyprinter.Render.String (renderString) import Data.Text (unpack,lines) #if !MIN_VERSION_base(4,8,0) import Data.Monoid (mconcat,mempty)
Text/LaTeX/Base/Syntax.hs view
@@ -99,18 +99,16 @@  -- Monoid instance for 'LaTeX'. --- | Method 'mappend' is strict in both arguments (except in the case when the first argument is 'TeXEmpty'). instance Monoid LaTeX where- mempty = TeXEmpty- mappend TeXEmpty x = x- mappend x TeXEmpty = x- -- This equation is to make 'mappend' associative.- mappend (TeXSeq x y) z = TeXSeq x $ mappend y z- --- mappend x y = TeXSeq x y+  mempty = TeXEmpty +-- | Appending is strict in both arguments (except when the first argument is 'TeXEmpty'). instance Semigroup.Semigroup LaTeX where-  (<>) = mappend+  TeXEmpty <> x = x+  x <> TeXEmpty = x+  -- This equation is to make 'mappend' associative.+  TeXSeq x y <> z = TeXSeq x $ y <> z+  x <> y = TeXSeq x y  -- | Calling 'between' @c l1 l2@ puts @c@ between @l1@ and @l2@ and --   appends them.
Text/LaTeX/Base/Warnings.hs view
@@ -49,10 +49,10 @@ checkFromFunction = TC  instance SG.Semigroup TeXCheck where- (<>) = mappend+ TC tc1 <> TC tc2 = TC $ uncurry (<>) . (tc1 &&& tc2)+ instance Monoid TeXCheck where  mempty = TC $ const []- mappend (TC tc1) (TC tc2) = TC $ uncurry mappend . (tc1 &&& tc2)  -- | Check with 'checkLabels', 'checkClass' and 'checkDoc'. checkAll :: TeXCheck
Text/LaTeX/Base/Writer.hs view
@@ -54,7 +54,6 @@    ) where  -- base-import Control.Monad (liftM, liftM2) import Control.Arrow import Data.String #if !MIN_VERSION_base(4,8,0)@@ -107,7 +106,6 @@  lift = LaTeXT . lift  instance Monad m => Monad (LaTeXT m) where- return = LaTeXT . return  (LaTeXT c) >>= f = LaTeXT $ do    a <- c   let LaTeXT c' = f a@@ -136,12 +134,12 @@ -- > myLaTeX = execLaTeXT anExample -- execLaTeXT :: Monad m => LaTeXT m a -> m LaTeX-execLaTeXT = liftM snd . runLaTeXT+execLaTeXT = fmap snd . runLaTeXT  -- | Version of 'execLaTeXT' with possible warning messages. --   This function applies 'checkAll' to the 'LaTeX' output. execLaTeXTWarn :: Monad m => LaTeXT m a -> m (LaTeX,[Warning])-execLaTeXTWarn = liftM (id &&& check checkAll) . execLaTeXT+execLaTeXTWarn = fmap (id &&& check checkAll) . execLaTeXT  -- | This function run a 'LaTeXT' computation, --   lifting the result again in the monad.@@ -158,7 +156,7 @@ -- is to implement the 'LaTeXC' instance of 'LaTeXT', which -- is closely related. extractLaTeX_ :: Monad m => LaTeXT m a -> LaTeXT m LaTeX-extractLaTeX_ = liftM snd . extractLaTeX+extractLaTeX_ = fmap snd . extractLaTeX  -- | With 'textell' you can append 'LaTeX' values to the --   state of the 'LaTeXT' monad.@@ -216,7 +214,6 @@  instance (Monad m, Monoid a) => Monoid (LaTeXT m a) where  mempty = return mempty- mappend = liftM2 mappend  instance (Applicative m, Semigroup.Semigroup a) => Semigroup.Semigroup (LaTeXT m a) where   (<>) = liftA2 (Semigroup.<>)
Text/LaTeX/Packages/BibLaTeX.hs view
@@ -19,6 +19,7 @@  , textC  , DOIReference  , ReferenceQueryT+ , applyDOIReferenceResolves  , masterBibFile  ) where @@ -63,6 +64,8 @@ printbibliography = comm0 "printbibliography"  +-- | All-inclusive preparation of a document containing DOI references.+--   Uses 'applyDOIReferenceResolves' under the hood. documentWithDOIReferences :: (MonadIO m, LaTeXC (m ()), SG.Semigroup (m ()), r ~ DOIReference)   => (r -> m (Maybe BibTeX.T)) -- ^ Reference-resolver function, for looking up BibTeX                                --   entries for a given DOI.@@ -75,7 +78,25 @@                                --   in @\\begin…end{document}@ here and an                                --   automatically-generated @.bib@ file included, but                                --   you still need to 'usepackage' 'biblatex' yourself.-documentWithDOIReferences resolver (ReferenceQueryT refq) = do+documentWithDOIReferences resolver docW = do+    (refsMap, docConts) <- applyDOIReferenceResolves resolver docW+    let bibfileConts = unlines $ BibTeX.entry . snd <$> Map.toList refsMap+        bibfileName = showHex (abs $ hash bibfileConts) $ ".bib"+    liftIO $ writeFile bibfileName bibfileConts+    () <- addbibresource bibfileName+    document docConts+    +-- | More manual version of 'documentWithDOIReferences', only retrieving suitable+--   BibTeX entries for the DOI-references contained in the document, but not+--   generating any @.bib@ files or wrapping the content in it.+applyDOIReferenceResolves :: (MonadIO m, LaTeXC (m ()), SG.Semigroup (m ()), r ~ DOIReference)+  => (r -> m (Maybe BibTeX.T)) -- ^ Reference-resolver function.+  -> ReferenceQueryT r m ()    -- ^ The document content.+  -> m ( Map.Map DOIReference BibTeX.T+       , m ())                 -- ^ All the BibTeX entries found, and a version of the+                               --   document with all its doi-references changed to point to+                               --   the identifiers in that file.+applyDOIReferenceResolves resolver (ReferenceQueryT refq) = do     (allRefs, (), useRefs) <- refq     resolved <- fmap catMaybes . forM (allRefs[]) $ \r -> do        r' <- resolver r@@ -83,11 +104,7 @@          Just entry -> Just (r, entry)          Nothing -> Nothing     let refsMap = Map.fromList resolved-        bibfileConts = unlines $ BibTeX.entry . snd <$> Map.toList refsMap-        bibfileName = showHex (abs $ hash bibfileConts) $ ".bib"-    liftIO $ writeFile bibfileName bibfileConts-    () <- addbibresource bibfileName-    document . useRefs $ \r flavour -> case Map.lookup r refsMap of+    return (refsMap, useRefs $ \r flavour -> case Map.lookup r refsMap of         Just a -> let citeC = liftL $ \l -> (`TeXComm`[FixArg l]) $ case flavour of                         Flavour_cite      -> "cite"                          Flavour_Cite      -> "Cite"@@ -101,6 +118,7 @@                         Flavour_Smartcite -> "Smartcite"                   in citeC . raw . fromString $ BibTeX.identifier a         Nothing -> makeshift r+     )  where makeshift :: (LaTeXC l, SG.Semigroup l) => DOIReference -> l        makeshift (DOIReference doi synops) = footnote $            fromLaTeX synops SG.<> ". DOI:" SG.<> fromString doi@@ -111,7 +129,7 @@ data DOIReference = DOIReference {        _referenceDOI :: PlainDOI      , _referenceSynopsis :: LaTeX-     } deriving (Generic)+     } deriving (Generic, Show) instance Eq DOIReference where   DOIReference doi₀ _ == DOIReference doi₁ _ = doi₀ == doi₁ instance Ord DOIReference where
license view
@@ -1,4 +1,4 @@-Copyright (c)2018, Daniel Díaz+Copyright (c)2023, Daniel Casanueva  All rights reserved. @@ -13,7 +13,7 @@       disclaimer in the documentation and/or other materials provided       with the distribution. -    * Neither the name of Daniel Díaz nor the names of other+    * Neither the name of Daniel Casanueva nor the names of other       contributors may be used to endorse or promote products derived       from this software without specific prior written permission. 
test/Main.hs view
@@ -1,14 +1,10 @@-{-# LANGUAGE CPP #-}  import Text.LaTeX+import Text.LaTeX.Base.Parser  import Test.Tasty import qualified Test.Tasty.QuickCheck as QC--#if !MIN_VERSION_parsec(3,1,9)-instance Eq ParseError where-  _ == _ = undefined-#endif+import Data.Either (isRight)  main :: IO () main = defaultMain $ testGroup "HaTeX"@@ -19,9 +15,8 @@     , QC.testProperty "LaTeX mappend" $          \l1 l2 l3 -> l1 <> (l2 <> l3) == (l1 <> l2) <> (l3 :: LaTeX)     ]---  , testGroup "Parser"---    [ QC.testProperty "render . parse = id" $---         \l -> let t = render (l :: LaTeX)---               in  fmap render (parseLaTeX t) == Right t---    ]+  , testGroup "Parser"+    [ QC.testProperty "isRight . parse . render" $+         \l -> isRight $ parseLaTeX (render (l :: LaTeX))+    ]   ]