HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduletexmath-0.13.3.1Haskell2010

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
  • 12 values
  • Packagetexmath-0.13.3.1
  • Exports14
  • LanguageHaskell2010
  • LicenceGPL-2.0-only
  • SourceTeXMath.hs
valuewriteTeX :: [Exp] -> Text
#

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

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

Transforms an expression tree to equivalent LaTeX with the specified packages

valuewriteStarMath :: DisplayType -> [Exp] -> Text
#

Render TeXMath expressions as StarMath syntax. Falls back to TeX output for expressions that are not yet supported.

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