Commit 5c50b8fb authored by Bastian Kauschke's avatar Bastian Kauschke
Browse files

cleanup printPolynomial

parent d803414d
......@@ -98,22 +98,22 @@ $(deriveShow1 ''Factor)
$(deriveShow1 ''Polynomial)
printPolynomial :: PrintConfig -> Polynomial Build.Builder -> Build.Builder
printPolynomial cfg (Polynomial (Sum (prods))) = fold (NonEmpty.intersperse " + " (fmap (printProduct cfg) prods))
printPolynomial _ (Polynomial (Sum (prods))) = fold (NonEmpty.intersperse " + " (fmap printProduct prods))
printProduct :: PrintConfig -> Product Build.Builder -> Build.Builder
printProduct cfg (Product (factors)) = fold (NonEmpty.intersperse "x" (fmap (printFactor cfg) factors))
printProduct :: Product Build.Builder -> Build.Builder
printProduct (Product (factors)) = fold (NonEmpty.intersperse "x" (fmap printFactor factors))
printFactor :: PrintConfig -> Factor Build.Builder -> Build.Builder
printFactor _ (Const IntSet) = "Z"
printFactor _ (Const NatSet) = "N"
printFactor _ (Const (FiniteNatSet v)) = Build.decimal v
printFactor _ (Const (ExplicitSet elems)) =
printFactor :: Factor Build.Builder -> Build.Builder
printFactor (Const IntSet) = "Z"
printFactor (Const NatSet) = "N"
printFactor (Const (FiniteNatSet v)) = Build.decimal v
printFactor (Const (ExplicitSet elems)) =
(V.foldl
(\s e -> s <> ", " <> Build.fromText e)
("{" <> Build.fromText (V.head elems)) (V.tail elems)
) <> "}"
printFactor _ (Identity a) = a
printFactor _ (Exponential a exp) = a <> "^" <> printExp exp
printFactor (Identity a) = a
printFactor (Exponential a exp) = a <> "^" <> printExp exp
printExp :: Exponent -> Build.Builder
printExp (FiniteNatExp v) = Build.decimal v
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment