{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Math.LaTeX.StringLiterals where
import qualified Text.LaTeX as LaTeX
import Text.LaTeX.Base.Syntax (LaTeX)
import qualified Text.LaTeX.Packages.AMSMath as LaTeX
import CAS.Dumb
import CAS.Dumb.Tree
import CAS.Dumb.Symbols
import Data.String
import Data.Char (isAlpha)
instance (SymbolClass σ, SCConstraint σ LaTeX)
=> IsString (CAS' γ (Infix LaTeX) (Encapsulation LaTeX) (SymbolD σ LaTeX)) where
fromString :: String
-> CAS' γ (Infix LaTeX) (Encapsulation LaTeX) (SymbolD σ LaTeX)
fromString String
s = forall γ s² s¹ s⁰. s⁰ -> CAS' γ s² s¹ s⁰
Symbol forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall σ c. c -> SymbolD σ c
StringSymbol forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(if forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Char -> Bool
isAlpha String
s then forall l. LaTeXC l => l -> l
LaTeX.mathrm
else forall a. a -> a
id) forall a b. (a -> b) -> a -> b
$ forall a. IsString a => String -> a
fromString String
s