{-# LANGUAGE GADTs #-}

-- | Defines functions to render 'CodeExpr's as printable 'P.Expr's.
module Language.Drasil.Printing.Import.CodeExpr (codeExpr) where

import Data.List (intersperse)

import Drasil.Code.CodeExpr.Development

import Drasil.Database (UID)
import Language.Drasil (DomainDesc(..), Inclusive(..),
  RTopology(..), RealInterval(..), LiteralC (int))
import qualified Language.Drasil.Display as S (Symbol(..))
import Language.Drasil.Literal.Development

import qualified Language.Drasil.Printing.AST as P
import Language.Drasil.Printing.PrintingInformation (PrintingInformation)
import Language.Drasil.Printing.Import.Helpers (lookupC', parens)
import Language.Drasil.Printing.Import.Literal (literal)
import Language.Drasil.Printing.Import.Symbol (symbol)

-- | Helper that creates an expression row given printing information, an operator, and an expression.
mkCall :: PrintingInformation -> P.Ops -> CodeExpr -> P.Expr
mkCall :: PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
s Ops
o CodeExpr
e = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
o, Expr -> Expr
parens (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
s CodeExpr
e]

-- | Helper that creates a binary expression row given printing information, an operator, and two expressions.
mkBOp :: PrintingInformation -> P.Ops -> CodeExpr -> CodeExpr -> P.Expr
mkBOp :: PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
o CodeExpr
a CodeExpr
b = [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a, Ops -> Expr
P.MO Ops
o, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
b]

-- | Helper that adds parenthesis to an expression where appropriate.
expr' :: PrintingInformation -> Int -> CodeExpr -> P.Expr
expr' :: PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
s Int
p CodeExpr
e = Expr -> Expr
fence (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
s CodeExpr
e
  where fence :: Expr -> Expr
fence = if CodeExpr -> Int
eprec CodeExpr
e Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
p then Expr -> Expr
parens else Expr -> Expr
forall a. a -> a
id

-- | Helper for properly rendering negation of expressions.
neg' :: CodeExpr -> Bool
neg' :: CodeExpr -> Bool
neg' (Lit (Dbl Double
_))          = Bool
True
neg' (Lit (Int Integer
_))          = Bool
True
neg' (Lit (ExactDbl Integer
_))     = Bool
True
neg' Operator{}             = Bool
True
neg' (AssocA AssocArithOper
Mul [CodeExpr]
_)        = Bool
True
neg' (LABinaryOp LABinOp
Index CodeExpr
_ CodeExpr
_) = Bool
True
neg' (UnaryOp UFunc
_ CodeExpr
_)          = Bool
True
neg' (UnaryOpB UFuncB
_ CodeExpr
_)         = Bool
True
neg' (UnaryOpVV UFuncVV
_ CodeExpr
_)        = Bool
True
neg' (C UID
_)                  = Bool
True
neg' CodeExpr
_                      = Bool
False

-- | Render negated expressions.
neg :: PrintingInformation -> CodeExpr -> P.Expr
neg :: PrintingInformation -> CodeExpr -> Expr
neg PrintingInformation
sm CodeExpr
a = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Neg, (if CodeExpr -> Bool
neg' CodeExpr
a then Expr -> Expr
forall a. a -> a
id else Expr -> Expr
parens) (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a]

-- | For printing indexes.
indx :: PrintingInformation -> CodeExpr -> CodeExpr -> P.Expr
indx :: PrintingInformation -> CodeExpr -> CodeExpr -> Expr
indx PrintingInformation
sm (C UID
c) CodeExpr
i = Symbol -> Expr
f Symbol
s
  where
    i' :: Expr
i' = PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
i
    s :: Symbol
s = PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
c
    f :: Symbol -> Expr
f (S.Corners [] [] [] [Symbol
b] Symbol
e) =
      let e' :: Expr
e' = Symbol -> Expr
symbol Symbol
e
          b' :: Expr
b' = Symbol -> Expr
symbol Symbol
b in
      [Expr] -> Expr
P.Row [[Expr] -> Expr
P.Row [Expr
e', Expr -> Expr
P.Sub ([Expr] -> Expr
P.Row [Expr
b', Ops -> Expr
P.MO Ops
P.Comma, Expr
i'])]] -- FIXME, extra Row
    f a :: Symbol
a@(S.Variable String
_) = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
a, Expr -> Expr
P.Sub Expr
i']
    f a :: Symbol
a@(S.Label String
_)    = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
a, Expr -> Expr
P.Sub Expr
i']
--    f a@(Greek _)  = P.Row [symbol a, P.Sub i']
    f   Symbol
e          = let e' :: Expr
e' = Symbol -> Expr
symbol Symbol
e in [Expr] -> Expr
P.Row [[Expr] -> Expr
P.Row [Expr
e'], Expr -> Expr
P.Sub Expr
i']
indx PrintingInformation
sm CodeExpr
a CodeExpr
i = [Expr] -> Expr
P.Row [[Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a], Expr -> Expr
P.Sub (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
i]

-- | For printing expressions that call something.
call :: PrintingInformation -> UID -> [CodeExpr] -> [(UID, CodeExpr)] -> P.Expr
call :: PrintingInformation
-> UID -> [CodeExpr] -> [(UID, CodeExpr)] -> Expr
call PrintingInformation
sm UID
f [CodeExpr]
ps [(UID, CodeExpr)]
ns = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
f,
  Expr -> Expr
parens (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
intersperse (Ops -> Expr
P.MO Ops
P.Comma) ([Expr] -> [Expr]) -> [Expr] -> [Expr]
forall a b. (a -> b) -> a -> b
$ (CodeExpr -> Expr) -> [CodeExpr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm) [CodeExpr]
ps [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++
  (UID -> CodeExpr -> Expr) -> [UID] -> [CodeExpr] -> [Expr]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\UID
n CodeExpr
a -> [Expr] -> Expr
P.Row [Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
n,
  Ops -> Expr
P.MO Ops
P.Eq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a]) (((UID, CodeExpr) -> UID) -> [(UID, CodeExpr)] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, CodeExpr) -> UID
forall a b. (a, b) -> a
fst [(UID, CodeExpr)]
ns) (((UID, CodeExpr) -> CodeExpr) -> [(UID, CodeExpr)] -> [CodeExpr]
forall a b. (a -> b) -> [a] -> [b]
map (UID, CodeExpr) -> CodeExpr
forall a b. (a, b) -> b
snd [(UID, CodeExpr)]
ns)]

-- | Helper function for addition 'EOperator's.
eopAdds :: PrintingInformation -> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> P.Expr
eopAdds :: forall (t :: RTopology).
PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
eopAdds PrintingInformation
sm (BoundedDD Symbol
v RTopology
Continuous CodeExpr
l CodeExpr
h) CodeExpr
e =
  [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Inte, Expr -> Expr
P.Sub (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
l), Expr -> Expr
P.Sup (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
h),
         [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e], Spacing -> Expr
P.Spc Spacing
P.Thin, String -> Expr
P.Ident String
"d", Symbol -> Expr
symbol Symbol
v]
eopAdds PrintingInformation
sm (AllDD Symbol
v RTopology
Continuous) CodeExpr
e =
  [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Inte, Expr -> Expr
P.Sub (Symbol -> Expr
symbol Symbol
v), [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e], Spacing -> Expr
P.Spc Spacing
P.Thin,
         String -> Expr
P.Ident String
"d", Symbol -> Expr
symbol Symbol
v]
eopAdds PrintingInformation
sm (BoundedDD Symbol
v RTopology
Discrete CodeExpr
l CodeExpr
h) CodeExpr
e =
  [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Summ, Expr -> Expr
P.Sub ([Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
v, Ops -> Expr
P.MO Ops
P.Eq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
l]), Expr -> Expr
P.Sup (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
h),
         [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e]]
eopAdds PrintingInformation
sm (AllDD Symbol
_ RTopology
Discrete) CodeExpr
e = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Summ, [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e]]

-- | Helper function for multiplicative 'EOperator's.
eopMuls :: PrintingInformation -> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> P.Expr
eopMuls :: forall (t :: RTopology).
PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
eopMuls PrintingInformation
sm (BoundedDD Symbol
v RTopology
Discrete CodeExpr
l CodeExpr
h) CodeExpr
e =
  [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Prod, Expr -> Expr
P.Sub ([Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
v, Ops -> Expr
P.MO Ops
P.Eq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
l]), Expr -> Expr
P.Sup (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
h),
         [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e]]
eopMuls PrintingInformation
sm (AllDD Symbol
_ RTopology
Discrete) CodeExpr
e = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Prod, [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
e]]
eopMuls PrintingInformation
_ (AllDD Symbol
_ RTopology
Continuous) CodeExpr
_ = String -> Expr
forall a. HasCallStack => String -> a
error String
"Printing/Import.hs Product-Integral not implemented."
eopMuls PrintingInformation
_ (BoundedDD Symbol
_ RTopology
Continuous CodeExpr
_ CodeExpr
_) CodeExpr
_ = String -> Expr
forall a. HasCallStack => String -> a
error String
"Printing/Import.hs Product-Integral not implemented."

-- | Helper function for translating 'EOperator's.
eop :: PrintingInformation -> AssocArithOper -> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> P.Expr
eop :: forall (t :: RTopology).
PrintingInformation
-> AssocArithOper
-> DomainDesc t CodeExpr CodeExpr
-> CodeExpr
-> Expr
eop PrintingInformation
sm AssocArithOper
Add = PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
forall (t :: RTopology).
PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
eopAdds PrintingInformation
sm
eop PrintingInformation
sm AssocArithOper
Mul = PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
forall (t :: RTopology).
PrintingInformation
-> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> Expr
eopMuls PrintingInformation
sm

-- | Translate 'CodeExpr's to printable layout AST 'Expr's.
codeExpr :: PrintingInformation -> CodeExpr -> P.Expr
codeExpr :: PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm (Lit Literal
l)                  = Literal -> PrintingInformation -> Expr
literal Literal
l PrintingInformation
sm
codeExpr PrintingInformation
sm (AssocB AssocBoolOper
And [CodeExpr]
l)           = Ops -> Int -> [CodeExpr] -> PrintingInformation -> Expr
assocExpr Ops
P.And (AssocBoolOper -> Int
precB AssocBoolOper
And) [CodeExpr]
l PrintingInformation
sm
codeExpr PrintingInformation
sm (AssocB AssocBoolOper
Or [CodeExpr]
l)            = Ops -> Int -> [CodeExpr] -> PrintingInformation -> Expr
assocExpr Ops
P.Or (AssocBoolOper -> Int
precB AssocBoolOper
Or) [CodeExpr]
l PrintingInformation
sm
codeExpr PrintingInformation
sm (AssocA AssocArithOper
Add [CodeExpr]
l)           = [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
addExpr [CodeExpr]
l AssocArithOper
Add PrintingInformation
sm
codeExpr PrintingInformation
sm (AssocA AssocArithOper
Mul [CodeExpr]
l)           = [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr [CodeExpr]
l AssocArithOper
Mul PrintingInformation
sm
codeExpr PrintingInformation
sm (AssocC AssocConcatOper
SUnion [CodeExpr]
l)        = [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr [CodeExpr]
l AssocArithOper
Mul PrintingInformation
sm
codeExpr PrintingInformation
sm (C UID
c)                    = Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
c
codeExpr PrintingInformation
sm (FCall UID
f [CodeExpr
x] [])         =
  [Expr] -> Expr
P.Row [Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
f, Expr -> Expr
parens (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
x]
codeExpr PrintingInformation
sm (FCall UID
f [CodeExpr]
l [(UID, CodeExpr)]
ns)           = PrintingInformation
-> UID -> [CodeExpr] -> [(UID, CodeExpr)] -> Expr
call PrintingInformation
sm UID
f [CodeExpr]
l [(UID, CodeExpr)]
ns
codeExpr PrintingInformation
sm (New UID
c [CodeExpr]
l [(UID, CodeExpr)]
ns)             = PrintingInformation
-> UID -> [CodeExpr] -> [(UID, CodeExpr)] -> Expr
call PrintingInformation
sm UID
c [CodeExpr]
l [(UID, CodeExpr)]
ns
codeExpr PrintingInformation
sm (Message UID
a UID
m [CodeExpr]
l [(UID, CodeExpr)]
ns)       =
  [Expr] -> Expr
P.Row [Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
a, Ops -> Expr
P.MO Ops
P.Point, PrintingInformation
-> UID -> [CodeExpr] -> [(UID, CodeExpr)] -> Expr
call PrintingInformation
sm UID
m [CodeExpr]
l [(UID, CodeExpr)]
ns]
codeExpr PrintingInformation
sm (Field UID
o UID
f)              = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
o,
  Ops -> Expr
P.MO Ops
P.Point, Symbol -> Expr
symbol (Symbol -> Expr) -> Symbol -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
f]
codeExpr PrintingInformation
sm (Case Completeness
_ [(CodeExpr, CodeExpr)]
ps)              =
  if [(CodeExpr, CodeExpr)] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(CodeExpr, CodeExpr)]
ps Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
2
    then String -> Expr
forall a. HasCallStack => String -> a
error String
"Attempting to use multi-case codeExpr incorrectly"
    else [(Expr, Expr)] -> Expr
P.Case ([Expr] -> [Expr] -> [(Expr, Expr)]
forall a b. [a] -> [b] -> [(a, b)]
zip (((CodeExpr, CodeExpr) -> Expr) -> [(CodeExpr, CodeExpr)] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm (CodeExpr -> Expr)
-> ((CodeExpr, CodeExpr) -> CodeExpr)
-> (CodeExpr, CodeExpr)
-> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeExpr, CodeExpr) -> CodeExpr
forall a b. (a, b) -> a
fst) [(CodeExpr, CodeExpr)]
ps) (((CodeExpr, CodeExpr) -> Expr) -> [(CodeExpr, CodeExpr)] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm (CodeExpr -> Expr)
-> ((CodeExpr, CodeExpr) -> CodeExpr)
-> (CodeExpr, CodeExpr)
-> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeExpr, CodeExpr) -> CodeExpr
forall a b. (a, b) -> b
snd) [(CodeExpr, CodeExpr)]
ps))
codeExpr PrintingInformation
sm (Matrix [[CodeExpr]]
a)                  = [[Expr]] -> Expr
P.Mtx ([[Expr]] -> Expr) -> [[Expr]] -> Expr
forall a b. (a -> b) -> a -> b
$ ([CodeExpr] -> [Expr]) -> [[CodeExpr]] -> [[Expr]]
forall a b. (a -> b) -> [a] -> [b]
map ((CodeExpr -> Expr) -> [CodeExpr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm)) [[CodeExpr]]
a
codeExpr PrintingInformation
sm (Set Space
_ [CodeExpr]
a)                   = [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ (CodeExpr -> Expr) -> [CodeExpr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm) [CodeExpr]
a
codeExpr PrintingInformation
sm (Variable String
_ CodeExpr
l)              = PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
l
codeExpr PrintingInformation
sm (UnaryOp UFunc
Log CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Log CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Ln CodeExpr
u)              = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Ln CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Sin CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Sin CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Cos CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Cos CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Tan CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Tan CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Sec CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Sec CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Csc CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Csc CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Cot CodeExpr
u)             = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Cot CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Arcsin CodeExpr
u)          = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Arcsin CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Arccos CodeExpr
u)          = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Arccos CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Arctan CodeExpr
u)          = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Arctan CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Exp CodeExpr
u)             = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Exp, Expr -> Expr
P.Sup (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
u]
codeExpr PrintingInformation
sm (UnaryOp UFunc
Abs CodeExpr
u)             = Fence -> Fence -> Expr -> Expr
P.Fenced Fence
P.Abs Fence
P.Abs (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOpB UFuncB
Not CodeExpr
u)            = [Expr] -> Expr
P.Row [Ops -> Expr
P.MO Ops
P.Not, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
u]
codeExpr PrintingInformation
sm (UnaryOpVN UFuncVN
Norm CodeExpr
u)          = Fence -> Fence -> Expr -> Expr
P.Fenced Fence
P.Norm Fence
P.Norm (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOpVN UFuncVN
Dim CodeExpr
u)           = PrintingInformation -> Ops -> CodeExpr -> Expr
mkCall PrintingInformation
sm Ops
P.Dim CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Sqrt CodeExpr
u)            = Expr -> Expr
P.Sqrt (Expr -> Expr) -> Expr -> Expr
forall a b. (a -> b) -> a -> b
$ PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOp UFunc
Neg CodeExpr
u)             = PrintingInformation -> CodeExpr -> Expr
neg PrintingInformation
sm CodeExpr
u
codeExpr PrintingInformation
sm (UnaryOpVV UFuncVV
NegV CodeExpr
u)          = PrintingInformation -> CodeExpr -> Expr
neg PrintingInformation
sm CodeExpr
u
codeExpr PrintingInformation
sm (ArithBinaryOp ArithBinOp
Frac CodeExpr
a CodeExpr
b)    = Expr -> Expr -> Expr
P.Div (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a) (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
b)
codeExpr PrintingInformation
sm (ArithBinaryOp ArithBinOp
Pow CodeExpr
a CodeExpr
b)     = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
pow PrintingInformation
sm CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (ArithBinaryOp ArithBinOp
Subt CodeExpr
a CodeExpr
b)    = [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
a, Ops -> Expr
P.MO Ops
P.Subt, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
sm CodeExpr
b]
codeExpr PrintingInformation
sm (BoolBinaryOp BoolBinOp
Impl CodeExpr
a CodeExpr
b)     = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Impl CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (BoolBinaryOp BoolBinOp
Iff CodeExpr
a CodeExpr
b)      = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Iff CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (EqBinaryOp EqBinOp
Eq CodeExpr
a CodeExpr
b)         = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Eq CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (EqBinaryOp EqBinOp
NEq CodeExpr
a CodeExpr
b)        = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.NEq CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (LABinaryOp LABinOp
Index CodeExpr
a CodeExpr
b)      = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
indx PrintingInformation
sm CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (LABinaryOp LABinOp
IndexOf CodeExpr
a CodeExpr
b)    = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
indx PrintingInformation
sm CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (OrdBinaryOp OrdBinOp
Lt CodeExpr
a CodeExpr
b)        = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Lt CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (OrdBinaryOp OrdBinOp
Gt CodeExpr
a CodeExpr
b)        = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Gt CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (OrdBinaryOp OrdBinOp
LEq CodeExpr
a CodeExpr
b)       = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.LEq CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (OrdBinaryOp OrdBinOp
GEq CodeExpr
a CodeExpr
b)       = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.GEq CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (VVNBinaryOp VVNBinOp
Dot CodeExpr
a CodeExpr
b)       = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Dot CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (VVVBinaryOp VVVBinOp
Cross CodeExpr
a CodeExpr
b)     = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Cross CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (VVVBinaryOp VVVBinOp
VAdd CodeExpr
a CodeExpr
b)      = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.VAdd CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (VVVBinaryOp VVVBinOp
VSub CodeExpr
a CodeExpr
b)      = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.VSub CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (NVVBinaryOp NVVBinOp
Scale CodeExpr
a CodeExpr
b)     = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.Scale CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (ESSBinaryOp ESSBinOp
SAdd CodeExpr
a CodeExpr
b)      = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.SAdd CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (ESSBinaryOp ESSBinOp
SRemove CodeExpr
a CodeExpr
b)   = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.SRemove CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (ESBBinaryOp ESBBinOp
SContains CodeExpr
a CodeExpr
b) = PrintingInformation -> Ops -> CodeExpr -> CodeExpr -> Expr
mkBOp PrintingInformation
sm Ops
P.SContains CodeExpr
a CodeExpr
b
codeExpr PrintingInformation
sm (Operator AssocArithOper
o DiscreteDomainDesc CodeExpr CodeExpr
d CodeExpr
e)            = PrintingInformation
-> AssocArithOper
-> DiscreteDomainDesc CodeExpr CodeExpr
-> CodeExpr
-> Expr
forall (t :: RTopology).
PrintingInformation
-> AssocArithOper
-> DomainDesc t CodeExpr CodeExpr
-> CodeExpr
-> Expr
eop PrintingInformation
sm AssocArithOper
o DiscreteDomainDesc CodeExpr CodeExpr
d CodeExpr
e
codeExpr PrintingInformation
sm (RealI UID
c RealInterval CodeExpr CodeExpr
ri)                = PrintingInformation
-> Symbol -> RealInterval CodeExpr CodeExpr -> Expr
renderRealInt PrintingInformation
sm (PrintingInformation -> UID -> Symbol
lookupC' PrintingInformation
sm UID
c) RealInterval CodeExpr CodeExpr
ri

-- | Common method of converting associative operations into printable layout AST.
assocExpr :: P.Ops -> Int -> [CodeExpr] -> PrintingInformation -> P.Expr
assocExpr :: Ops -> Int -> [CodeExpr] -> PrintingInformation -> Expr
assocExpr Ops
op Int
prec [CodeExpr]
exprs PrintingInformation
sm = [Expr] -> Expr
P.Row ([Expr] -> Expr) -> [Expr] -> Expr
forall a b. (a -> b) -> a -> b
$ Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
intersperse (Ops -> Expr
P.MO Ops
op) ([Expr] -> [Expr]) -> [Expr] -> [Expr]
forall a b. (a -> b) -> a -> b
$ (CodeExpr -> Expr) -> [CodeExpr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm Int
prec) [CodeExpr]
exprs

-- | Helper for rendering printable expressions.
addExpr :: [CodeExpr] -> AssocArithOper -> PrintingInformation -> [P.Expr]
addExpr :: [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
addExpr [CodeExpr]
exprs AssocArithOper
o PrintingInformation
sm = [Expr] -> [Expr]
addExprFilter ((CodeExpr -> Expr) -> [CodeExpr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map (PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o)) [CodeExpr]
exprs)

-- | Add add symbol only when the second Expr is not negation
addExprFilter :: [P.Expr] -> [P.Expr]
addExprFilter :: [Expr] -> [Expr]
addExprFilter [] = []
addExprFilter [Expr
x] = [Expr
x]
addExprFilter (Expr
x1:P.Row[P.MO Ops
P.Neg, Expr
x2]:[Expr]
xs) = Expr
x1 Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: [Expr] -> [Expr]
addExprFilter ([Expr] -> Expr
P.Row[Ops -> Expr
P.MO Ops
P.Neg, Expr
x2] Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: [Expr]
xs)
addExprFilter (Expr
x:[Expr]
xs) = Expr
x Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: Ops -> Expr
P.MO Ops
P.Add Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: [Expr] -> [Expr]
addExprFilter [Expr]
xs

-- | Helper for rendering printable expressions.
mulExpr ::  [CodeExpr] -> AssocArithOper -> PrintingInformation -> [P.Expr]
mulExpr :: [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr (CodeExpr
hd1:CodeExpr
hd2:[CodeExpr]
tl) AssocArithOper
o PrintingInformation
sm = case (CodeExpr
hd1, CodeExpr
hd2) of
  (CodeExpr
a, Lit (Int Integer
_))      ->  [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) CodeExpr
a, Ops -> Expr
P.MO Ops
P.Dot] [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr (CodeExpr
hd2 CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
tl) AssocArithOper
o PrintingInformation
sm
  (CodeExpr
a, Lit (ExactDbl Integer
_)) ->  [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) CodeExpr
a, Ops -> Expr
P.MO Ops
P.Dot] [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr (CodeExpr
hd2 CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
tl) AssocArithOper
o PrintingInformation
sm
  (CodeExpr
a, Lit (Dbl Double
_))      ->  [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) CodeExpr
a, Ops -> Expr
P.MO Ops
P.Dot] [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr (CodeExpr
hd2 CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
tl) AssocArithOper
o PrintingInformation
sm
  (CodeExpr
a, CodeExpr
_)                ->  [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) CodeExpr
a, Ops -> Expr
P.MO Ops
P.Mul] [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr] -> AssocArithOper -> PrintingInformation -> [Expr]
mulExpr (CodeExpr
hd2 CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
tl) AssocArithOper
o PrintingInformation
sm
mulExpr [CodeExpr
hd]         AssocArithOper
o PrintingInformation
sm = [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) CodeExpr
hd]
mulExpr []           AssocArithOper
o PrintingInformation
sm = [PrintingInformation -> Int -> CodeExpr -> Expr
expr' PrintingInformation
sm (AssocArithOper -> Int
precA AssocArithOper
o) (Integer -> CodeExpr
forall r. LiteralC r => Integer -> r
int Integer
1)]

-- | Helper that adds parenthesis to the first expression. The second expression
-- is written as a superscript attached to the first.
withParens :: PrintingInformation -> CodeExpr -> CodeExpr -> P.Expr
withParens :: PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b = [Expr] -> Expr
P.Row [Expr -> Expr
parens (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
prI CodeExpr
a), Expr -> Expr
P.Sup (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
prI CodeExpr
b)]

-- | Helper for properly rendering exponents.
pow :: PrintingInformation -> CodeExpr -> CodeExpr -> P.Expr
pow :: PrintingInformation -> CodeExpr -> CodeExpr -> Expr
pow PrintingInformation
prI a :: CodeExpr
a@(AssocA AssocArithOper
Add [CodeExpr]
_)          CodeExpr
b = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b
pow PrintingInformation
prI a :: CodeExpr
a@(AssocA AssocArithOper
Mul [CodeExpr]
_)         CodeExpr
b = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b
pow PrintingInformation
prI a :: CodeExpr
a@(ArithBinaryOp ArithBinOp
Subt CodeExpr
_ CodeExpr
_) CodeExpr
b = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b
pow PrintingInformation
prI a :: CodeExpr
a@(ArithBinaryOp ArithBinOp
Frac CodeExpr
_ CodeExpr
_) CodeExpr
b = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b
pow PrintingInformation
prI a :: CodeExpr
a@(ArithBinaryOp ArithBinOp
Pow CodeExpr
_ CodeExpr
_)  CodeExpr
b = PrintingInformation -> CodeExpr -> CodeExpr -> Expr
withParens PrintingInformation
prI CodeExpr
a CodeExpr
b
pow PrintingInformation
prI CodeExpr
a                          CodeExpr
b = [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
prI CodeExpr
a, Expr -> Expr
P.Sup (PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
prI CodeExpr
b)]

-- | Print a 'RealInterval'.
renderRealInt :: PrintingInformation -> S.Symbol -> RealInterval CodeExpr CodeExpr -> P.Expr
renderRealInt :: PrintingInformation
-> Symbol -> RealInterval CodeExpr CodeExpr -> Expr
renderRealInt PrintingInformation
st Symbol
s (Bounded (Inclusive
Inc,CodeExpr
a) (Inclusive
Inc,CodeExpr
b)) =
  [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a, Ops -> Expr
P.MO Ops
P.LEq, Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.LEq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
b]
renderRealInt PrintingInformation
st Symbol
s (Bounded (Inclusive
Inc,CodeExpr
a) (Inclusive
Exc,CodeExpr
b)) =
  [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a, Ops -> Expr
P.MO Ops
P.LEq, Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.Lt, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
b]
renderRealInt PrintingInformation
st Symbol
s (Bounded (Inclusive
Exc,CodeExpr
a) (Inclusive
Inc,CodeExpr
b)) =
  [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a, Ops -> Expr
P.MO Ops
P.Lt, Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.LEq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
b]
renderRealInt PrintingInformation
st Symbol
s (Bounded (Inclusive
Exc,CodeExpr
a) (Inclusive
Exc,CodeExpr
b)) =
  [Expr] -> Expr
P.Row [PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a, Ops -> Expr
P.MO Ops
P.Lt, Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.Lt, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
b]
renderRealInt PrintingInformation
st Symbol
s (UpTo (Inclusive
Inc,CodeExpr
a))   = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.LEq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a]
renderRealInt PrintingInformation
st Symbol
s (UpTo (Inclusive
Exc,CodeExpr
a))   = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.Lt,  PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a]
renderRealInt PrintingInformation
st Symbol
s (UpFrom (Inclusive
Inc,CodeExpr
a)) = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.GEq, PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a]
renderRealInt PrintingInformation
st Symbol
s (UpFrom (Inclusive
Exc,CodeExpr
a)) = [Expr] -> Expr
P.Row [Symbol -> Expr
symbol Symbol
s, Ops -> Expr
P.MO Ops
P.Gt,  PrintingInformation -> CodeExpr -> Expr
codeExpr PrintingInformation
st CodeExpr
a]