htoml-megaparsec 1.0.1.1 → 1.0.1.2
raw patch · 3 files changed
+10/−10 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Text.Toml.Types: throwParser :: (MonadPlus m, Alternative m, Ord e, MonadParsec e s m) => String -> m a
Files
- htoml-megaparsec.cabal +2/−3
- src/Text/Toml/Parser.hs +5/−5
- src/Text/Toml/Types.hs +3/−2
htoml-megaparsec.cabal view
@@ -1,10 +1,9 @@ name: htoml-megaparsec-version: 1.0.1.1+version: 1.0.1.2 synopsis: Parser for TOML files description: TOML is an obvious and minimal format for config files. This package provides a TOML parser- built with the Megaparsec. It exposes a JSON- interface using Aeson.+ built with the Megaparsec. homepage: https://github.com/vmchale/htoml-megaparsec bug-reports: https://github.com/vmchale/htoml-megaparsec/issues license: BSD3
src/Text/Toml/Parser.hs view
@@ -33,7 +33,7 @@ import Text.Toml.Types --- Imported as last to fix redundancy warning+-- Imported last to fix redundancy warning import Prelude hiding (concat, takeWhile) @@ -59,7 +59,7 @@ table = do pairs <- (many (assignment <* skipBlanks) <|> (skipBlanks >> return [])) case maybeDupe (map fst pairs) of- Just k -> fail $ "Cannot redefine key " ++ unpack k+ Just k -> throwParser $ "Cannot redefine key " ++ unpack k Nothing -> return $ M.fromList pairs -- | Parses an inline table of key-value pairs.@@ -67,7 +67,7 @@ inlineTable = do pairs <- between (char '{') (char '}') (skipSpaces *> separatedValues <* skipSpaces) case maybeDupe (map fst pairs) of- Just k -> fail $ "Cannot redefine key " ++ (unpack k)+ Just k -> throwParser $ "Cannot redefine key " ++ (unpack k) Nothing -> return $ VTable $ M.fromList pairs where skipSpaces = many (satisfy isSpc)@@ -133,7 +133,7 @@ <|> (try datetime <?> "datetime") <|> (try float <?> "float") <|> (try integer <?> "integer")- <|> (try inlineTable <?> "inline table")+ <|> (inlineTable <?> "inline table") --@@ -205,7 +205,7 @@ let mt = parseTime defaultTimeLocale (iso8601DateFormat $ Just "%X") d #endif case mt of Just t -> return $ VDatetime t- Nothing -> fail "parsing datetime failed"+ Nothing -> throwParser "parsing datetime failed" -- | Attoparsec 'double' parses scientific "e" notation; reimplement according to Toml spec.
src/Text/Toml/Types.hs view
@@ -14,6 +14,7 @@ , Explicitness (..) , isExplicit , insert+ , throwParser , Toml , TomlM , Parser@@ -92,7 +93,7 @@ insert ex ([name], node) ttbl = -- In case 'name' is final (a top-level name) case M.lookup name ttbl of- Nothing -> do when (isExplicit ex) $ updateExState [name] node+ Nothing -> do when (isExplicit ex) $ updateExStateOrError [name] node return $ M.insert name node ttbl Just (VTable t) -> case node of (VTable nt) -> case merge t nt of@@ -110,7 +111,7 @@ case M.lookup name ttbl of Nothing -> do r <- insert Implicit (ns, node) emptyTable- when (isExplicit ex) $ updateExState fullName node+ when (isExplicit ex) $ updateExStateOrError fullName node return $ M.insert name (VTable r) ttbl Just (VTable t) -> do r <- insert Implicit (ns, node) t