refactor a bit.
diff --git a/Parser.hs b/Parser.hs
index b69d01c..61cc167 100644
--- a/Parser.hs
+++ b/Parser.hs
@@ -35,6 +35,9 @@ braces = Tok.braces lexer
str = Tok.stringLiteral lexer
semiList = Tok.semiSep1 lexer
+oneOfSymbols :: [String] -> MParser String
+oneOfSymbols lst = choice $ map (try . symbol) lst
+
maybeList :: MParser a -> MParser [a]
maybeList p = option [] $ braces (p `sepEndBy1` (symbol ";"))
@@ -46,12 +49,12 @@ pDeclaration =
pShape :: MParser Shape
pShape = do
- s <- choice $ map (try . symbol) ["box", "rbox", "oval", "drum"]
+ s <- oneOfSymbols ["box", "rbox", "oval", "drum"]
return $ read $ capitalize s
pDirection :: MParser Direction
pDirection = do
- s <- choice $ map (try . symbol) ["horizontal", "vertical"]
+ s <- oneOfSymbols ["horizontal", "vertical"]
return $ read $ capitalize s
pEntity :: Direction -> MParser Entity