Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add 'Num' instance for 'LaTeXT'. Fixed 'cite' type signature. Exporti…

…ng of 'liftIO'.
  • Loading branch information...
commit 75f3cdef6d85089ce0e6e146b2d5a35a991c5d7d 1 parent 1578ba0
Daniel Diaz authored
View
6 HaTeX.cabal
@@ -1,14 +1,14 @@
Name: HaTeX
-Version: 3.3
+Version: 3.3.1
Author: Daniel Díaz
Category: Text
Build-type: Simple
License: BSD3
License-file: license
-Maintainer: Daniel Díaz (danieldiaz <at> dhelta <dot> net)
+Maintainer: Daniel Díaz (danieldiaz `at` dhelta `dot` net)
Stability: Experimental
Homepage: http://dhelta.net/hprojects/HaTeX
-Bug-reports: danieldiaz <at> dhelta <dot> net
+Bug-reports: danieldiaz `at` dhelta `dot` net
Synopsis: The Haskell LaTeX library.
Description: As it is said: \"LaTeX is a high-quality typesetting system\". This library provides
a bridge between that system and Haskell (i.e. it is a LaTeX DSL).
View
26 Text/LaTeX/Base.hs
@@ -17,7 +17,9 @@ to work with HaTeX. Those things are:
* The "Text.LaTeX.Base.Commands" module, which exports the LaTeX standard commands
and environments.
-Here is also defined a 'Num' instance for 'LaTeX'.
+* The "Text.LaTeX.Base.Writer" module, to work with the monad interface of the library.
+
+Here is also defined a 'Num' instance for both 'LaTeX' and 'LaTeXT'.
-}
module Text.LaTeX.Base
( -- * @LaTeX@ datatype
@@ -40,6 +42,7 @@ module Text.LaTeX.Base
) where
import Text.LaTeX.Base.Syntax (LaTeX (..),(<>),protectString,protectText)
+import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Render
import Text.LaTeX.Base.Types
import Text.LaTeX.Base.Commands
@@ -47,7 +50,7 @@ import Text.LaTeX.Base.Writer
--
import Data.Monoid
--- Num instance for LaTeX
+-- Num instances for LaTeX and LaTeXT
-- | Methods 'abs' and 'signum' are undefined. Don't use them!
instance Num LaTeX where
@@ -59,3 +62,22 @@ instance Num LaTeX where
-- Non-defined methods
abs _ = error "Cannot use \"abs\" Num method with a LaTeX value."
signum _ = error "Cannot use \"signum\" Num method with a LaTeX value."
+
+-- | Warning: this instance only exist for the 'Num' instance.
+instance Monad m => Eq (LaTeXT m a) where
+ _ == _ = error "Cannot use \"(==)\" Eq method with a LaTeXT value."
+
+-- | Warning: this instance only exist for the 'Num' instance.
+instance Monad m => Show (LaTeXT m a) where
+ show _ = error "Cannot use \"show\" Show method with a LaTeXT value."
+
+-- | Methods 'abs' and 'signum' are undefined. Don't use them!
+instance Monad m => Num (LaTeXT m a) where
+ (+) = liftOp (+)
+ (-) = liftOp (-)
+ (*) = (>>)
+ negate = (mempty -)
+ fromInteger = fromLaTeX . fromInteger
+ -- Non-defined methods
+ abs _ = error "Cannot use \"abs\" Num method with a LaTeXT value."
+ signum _ = error "Cannot use \"signum\" Num method with a LaTeXT value."
View
2  Text/LaTeX/Base/Commands.hs
@@ -360,7 +360,7 @@ figure (Just p) = liftL $ TeXEnv "figure" [ OptArg $ TeXRaw $ render p ]
abstract :: LaTeXC l => l -> l
abstract = liftL $ TeXEnv "abstract" []
-cite :: LaTeX -> LaTeX
+cite :: LaTeXC l => l -> l
cite = liftL $ \l -> TeXComm "cite" [FixArg l]
-- Document class
View
1  Text/LaTeX/Base/Writer.hs
@@ -45,6 +45,7 @@ module Text.LaTeX.Base.Writer
, merror
-- * Re-export
, lift
+ , liftIO
) where
import Control.Monad.Trans.Writer
View
2  Text/LaTeX/Packages/AMSMath.hs
@@ -184,7 +184,7 @@ epsilon :: LaTeXC l => l
epsilon = comm0 "epsilon"
varepsilon :: LaTeXC l => l
-varepsilon = comm0 "epsilon"
+varepsilon = comm0 "varepsilon"
zeta :: LaTeXC l => l
zeta = comm0 "zeta"
Please sign in to comment.
Something went wrong with that request. Please try again.