HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletexmath-0.12.8.9Haskell2010

Text.TeXMath

Functions for converting between different representations of mathematical formulas.

Also note that in general writeLaTeX . readLaTeX /= id.

A typical use is to combine together a reader and writer.

import Control.Applicative ((<$>))
import Data.Text (Text)
import Text.TeXMath (writeMathML, readTeX)

texMathToMathML :: DisplayType -> Text -> Either Text Element
texMathToMathML dt s = writeMathML dt <$> readTeX s

It is also possible to manipulate the AST using Data.Generics. For example, if you wanted to replace all occurences of the identifier x in your expression, you do could do so with the following script.

{-# LANGUAGE OverloadedStrings -#}

import Control.Applicative ((<$>))
import Data.Text (Text)
import Data.Generics (everywhere, mkT)
import Text.TeXMath (writeMathML, readTeX)
import Text.TeXMath.Types
import Text.XML.Light (Element)

changeIdent :: Exp -> Exp
changeIdent (EIdentifier "x") = EIdentifier "y"
changeIdent e = e

texToMMLWithChangeIdent :: DisplayType -> Text -> Either Text Element
texToMMLWithChangeIdent dt s =
  writeMathML dt . everywhere (mkT changeIdent) <$> readTeX s
  • 2 types
  • 11 values
  • Packagetexmath-0.12.8.9
  • Exports13
  • LanguageHaskell2010
  • LicenceGPL-2.0-only
  • SourceTeXMath.hs
valuewriteTeX :: [Exp] -> Text
#

Transforms an expression tree to equivalent LaTeX with the default packages (amsmath and amssymb)

valuewriteTeXWith :: Env -> [Exp] -> Text
#

Transforms an expression tree to equivalent LaTeX with the specified packages

datadata Exp
#
Instances5Eq, Data, Ord, Read, Show
  • Eq ExpDefined in texmath-0.12.8.9 · Text.TeXMath.Types
  • Data ExpDefined in texmath-0.12.8.9 · Text.TeXMath.Types
  • Ord ExpDefined in texmath-0.12.8.9 · Text.TeXMath.Types
  • Read ExpDefined in texmath-0.12.8.9 · Text.TeXMath.Types
  • Show ExpDefined in texmath-0.12.8.9 · Text.TeXMath.Types