module Text.Numeral.Exp.Reified ( Exp(..), showExp, Side(L, R) ) where
import "base" Data.Bool ( Bool(False, True) )
import "base" Data.Eq ( Eq )
import "base" Data.List ( (++) )
import "base" Prelude ( String )
import "base" Text.Show ( Show, show )
import "base-unicode-symbols" Prelude.Unicode ( ℤ )
import qualified "this" Text.Numeral.Exp as E
data Exp i
= Unknown
| Lit ℤ
| Neg (Exp i)
| Add (Exp i) (Exp i)
| Mul (Exp i) (Exp i)
| Sub (Exp i) (Exp i)
| Frac (Exp i) (Exp i)
| Scale ℤ ℤ (Exp i)
| Dual (Exp i)
| Plural (Exp i)
| Inflection (i → i) (Exp i)
infixl 6 `Add`
infixl 6 `Sub`
infixl 7 `Mul`
showExp ∷ Exp i → String
showExp Unknown = "Unknown"
showExp (Lit n) = "Lit " ++ show n
showExp (Neg x) = "Neg (" ++ showExp x ++ ")"
showExp (Add x y) = "Add (" ++ showExp x ++ ") (" ++ showExp y ++ ")"
showExp (Mul x y) = "Mul (" ++ showExp x ++ ") (" ++ showExp y ++ ")"
showExp (Sub x y) = "Sub (" ++ showExp x ++ ") (" ++ showExp y ++ ")"
showExp (Frac x y) = "Frac (" ++ showExp x ++ ") (" ++ showExp y ++ ")"
showExp (Scale b o r) = "Scale " ++ show b ++ " " ++ show o ++ " (" ++ showExp r ++ ")"
showExp (Dual x) = "Dual (" ++ showExp x ++ ")"
showExp (Plural x) = "Plural (" ++ showExp x ++ ")"
showExp (Inflection _ x) = "Inflection <func> (" ++ showExp x ++ ")"
instance E.Unknown (Exp i) where
unknown = Unknown
isUnknown Unknown = True
isUnknown _ = False
instance E.Lit (Exp i) where lit = Lit
instance E.Neg (Exp i) where neg = Neg
instance E.Add (Exp i) where add = Add
instance E.Mul (Exp i) where mul = Mul
instance E.Sub (Exp i) where sub = Sub
instance E.Frac (Exp i) where frac = Frac
instance E.Scale (Exp i) where scale = Scale
instance E.Dual (Exp i) where dual = Dual
instance E.Plural (Exp i) where plural = Plural
instance E.Inflection (Exp i) where
#if __GLASGOW_HASKELL__ < 704
type E.Inf (Exp i) = i
#else
type Inf (Exp i) = i
#endif
inflection = Inflection
data Side = L
| R
deriving (Eq, Show)