Commit 519c317a authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Allow unicode for multiplication symbol

parent adf60b5e
......@@ -82,7 +82,8 @@ parseSumExpr inner = do
parseProductExpr :: MonadParser m => m a -> m (Product a)
parseProductExpr inner = do
left <- parseFactorExpr inner
rest <- many (L.symbol "x" *> parseFactorExpr inner)
let multSign = L.symbol "x" <|> L.symbol "×"
rest <- many (multSign *> parseFactorExpr inner)
return $ Product (left :| rest)
parseFactorExpr :: MonadParser m => m a -> m (Factor a)
......
......@@ -49,6 +49,9 @@ functorExpressionSpec = describe "functorExpression" $ do
p "X x {b}" `shouldParse` (Functor 1 (mkPoly [[ident, c ["b"]]]))
p "{a} x X" `shouldParse` (Functor 1 (mkPoly [[c ["a"], ident]]))
it "allows to use the unicode multiplication sign for products" $
p "X×X" `shouldParse` (Functor 1 (mkPoly [[ident, ident]]))
it "parses a co-product" $ do
p "X + X" `shouldParse` (Functor 1 (mkPoly [[ident], [ident]]))
p "{a} + {b}" `shouldParse` (Functor 1 (mkPoly [[c ["a"]], [c ["b"]]]))
......@@ -288,6 +291,7 @@ refineSpec = describe "refining" $ do
let Right enc = res
part <- stToIO (refine (Proxy @(Desorted Polynomial)) enc)
(Part.numBlocks part) `shouldBe` 4
-- Helpers
mkPoly :: [[Factor a]] -> Polynomial a
......
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