Commit 21defe06 authored by md9ms's avatar md9ms
Browse files

Get rid of anyOf (choice . map try works just as fine)

parent 0143844c
......@@ -230,13 +230,6 @@ splitLines = merge . filter validLine . lines
(fld, ':':val) -> (map toLower fld, dropWhile isSpace val)
(fld, "") -> error "FIXME"
-- |A parser for any of the given parsers. This actually seems to
-- behave differently from "choice".
anyOf :: [GenParser tok st a] -> GenParser tok st a
anyOf [a] = a
anyOf (h:t) = foldl ((<|>) . try) (try h) t
-- |parse a module name
moduleName = many (alphaNum <|> oneOf "_'.") <?> "moduleName"
......@@ -249,10 +242,6 @@ parseFilePath = liftM concat (many1 (
))
<?> "parseFilePath"
parseLicense :: GenParser Char st License
parseLicense = anyOf [string s>>return l | (s,l) <- licenses]
<?> "parseLicense"
parseDependency :: GenParser Char st Dependency
parseDependency = do name <- many1 (letter <|> digit <|> oneOf "-_")
skipMany parseWhite
......@@ -261,6 +250,10 @@ parseDependency = do name <- many1 (letter <|> digit <|> oneOf "-_")
return $ Dependency name ver
<?> "parseDependency"
parseLicense :: GenParser Char st License
parseLicense = choice [ try (string s >> return l) | (s,l) <- licenses]
<?> "parseLicense"
-- |Mapping between the licenses and their names
licenses :: [(String, License)]
licenses= [("GPL", GPL),
......
Markdown is supported
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