Integrate e -> functionToDoc "integrate" [toDoc e]
ConstReal r -> double r
ConstInteger i -> integer i
- ConstComplex c -> parens $ text ((show $ realPart c) ++ " + i*" ++ (show $ imagPart c) ++ ")")
+ ConstComplex c -> parens $ text $ showComplex c
LatticeComponent i -> text $ "lattice[" ++ i ++ "]"
Negate e -> hcat [text "(", toDoc e, text ")"]
Sum e i -> functionToDoc "sum" [toDoc e, text i]
where
binaryToDoc op lhs rhs = parens $ hcat [toDoc lhs, text op, toDoc rhs]
functionToDoc name params = text name <> (parens $ hcat (intersperse (text ", ") params))
+ showComplex c
+ | imagPart c == 0 = show $ realPart c
+ | realPart c == 0 = (show $ imagPart c) ++ "i"
+ | otherwise = concat [show $ realPart c, "+", show $ imagPart c, "i"]
data Assignment =
Assign Expression Expression