packages feed

htoml-megaparsec 1.0.1.2 → 1.0.1.3

raw patch · 3 files changed

+30/−29 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

htoml-megaparsec.cabal view
@@ -1,5 +1,5 @@ name:                     htoml-megaparsec-version:                  1.0.1.2+version:                  1.0.1.3 synopsis:                 Parser for TOML files description:              TOML is an obvious and minimal format for config files.                           This package provides a TOML parser@@ -75,7 +75,7 @@  benchmark benchmarks   hs-source-dirs:         benchmarks .-  ghc-options:            -O2 -Wall -threaded -rtsopts -with-rtsopts=-N+  ghc-options:            -O2 -Wall   main-is:                Benchmarks.hs   type:                   exitcode-stdio-1.0   default-language:       Haskell2010
src/Text/Toml/Parser.hs view
@@ -12,6 +12,7 @@ import           Control.Applicative  hiding (many, optional, (<|>)) import           Control.Monad import           Control.Monad.State  (evalState)+import           Data.Char            (isAsciiLower, isAsciiUpper, isDigit) import qualified Data.HashMap.Strict  as M import qualified Data.Set             as S import           Data.Text            (Text, pack, unpack)@@ -57,7 +58,7 @@ -- | Parses a table of key-value pairs. table :: (TomlM m) => Parser m Table table = do-    pairs <- (many (assignment <* skipBlanks) <|> (skipBlanks >> return []))+    pairs <- many (assignment <* skipBlanks) <|> (skipBlanks >> return [])     case maybeDupe (map fst pairs) of       Just k  -> throwParser $ "Cannot redefine key " ++ unpack k       Nothing -> return $ M.fromList pairs@@ -67,7 +68,7 @@ inlineTable = do     pairs <- between (char '{') (char '}') (skipSpaces *> separatedValues <* skipSpaces)     case maybeDupe (map fst pairs) of-      Just k  -> throwParser $ "Cannot redefine key " ++ (unpack k)+      Just k  -> throwParser $ "Cannot redefine key " ++ unpack k       Nothing -> return $ VTable $ M.fromList pairs   where     skipSpaces      = many (satisfy isSpc)@@ -109,7 +110,7 @@  -- | Parses the value of any header (names separated by dots), into a list of 'Text'. headerValue :: (TomlM m) => Parser m [Text]-headerValue = ((pack <$> some keyChar) <|> anyStr') `sepBy1` (char '.')+headerValue = ((pack <$> some keyChar) <|> anyStr') `sepBy1` char '.'   where     keyChar = alphaNumChar <|> char '_' <|> char '-' @@ -150,8 +151,8 @@   boolean :: (TomlM m) => Parser m Node-boolean = VBoolean <$> ( (string $ "true")  *> return True  <|>-                         (string $ "false") *> return False )+boolean = VBoolean <$> ( string "true"  *> return True  <|>+                         string "false" *> return False )   anyStr :: (TomlM m) => Parser m Node@@ -162,23 +163,23 @@   basicStr :: (TomlM m) => Parser m Text-basicStr = between dQuote dQuote (fmap pack $ many strChar)+basicStr = between dQuote dQuote (pack <$> many strChar)   where     strChar = escSeq <|> noneOf ("\"\\" :: String) --satisfy (\c -> c /= '"' && c /= '\\'))     dQuote  = char '\"'   multiBasicStr :: (TomlM m) => Parser m Text-multiBasicStr = (openDQuote3 *> escWhiteSpc *> (pack <$> manyTill strChar (try dQuote3)))+multiBasicStr = openDQuote3 *> escWhiteSpc *> (pack <$> manyTill strChar (try dQuote3))   where     -- | Parse the a tripple-double quote, with possibly a newline attached     openDQuote3 = try (dQuote3 <* char '\n') <|> try dQuote3     -- | Parse tripple-double quotes     dQuote3     = count 3 $ char '"'     -- | Parse a string char, accepting escaped codes, ignoring escaped white space-    strChar     = (escSeq <|> (satisfy (/= '\\'))) <* escWhiteSpc+    strChar     = escSeq <|> satisfy (/= '\\') <* escWhiteSpc     -- | Parse escaped white space, if any-    escWhiteSpc = many $ char '\\' >> char '\n' >> (many $ satisfy (\c -> isSpc c || c == '\n'))+    escWhiteSpc = many $ char '\\' >> char '\n' >> many (satisfy (\c -> isSpc c || c == '\n'))   literalStr :: (TomlM m) => Parser m Text@@ -188,7 +189,7 @@   multiLiteralStr :: (TomlM m) => Parser m Text-multiLiteralStr = (openSQuote3 *> (fmap pack $ manyTill anyChar sQuote3))+multiLiteralStr = openSQuote3 *> (pack <$> manyTill anyChar sQuote3)   where     -- | Parse the a tripple-single quote, with possibly a newline attached     openSQuote3 = try (sQuote3 <* char '\n') <|> try sQuote3@@ -224,9 +225,9 @@   integer :: (TomlM m) => Parser m Node-integer = VInteger <$> (signed $ read <$> uintStr)+integer = VInteger <$> signed (read <$> uintStr)   where-    uintStr :: (TomlM m) => Parser m [Char]+    uintStr :: (TomlM m) => Parser m String     uintStr = (:) <$> digitChar <*> many (optional (char '_') *> digitChar)  --@@ -246,16 +247,16 @@ escSeq :: (TomlM m) => Parser m Char escSeq = char '\\' *> escSeqChar   where-    escSeqChar =  (char '"')  *> return '"'-              <|> (char '\\') *> return '\\'-              <|> (char '/')  *> return '/'-              <|> (char 'b')  *> return '\b'-              <|> (char 't')  *> return '\t'-              <|> (char 'n')  *> return '\n'-              <|> (char 'f')  *> return '\f'-              <|> (char 'r')  *> return '\r'-              <|> (char 'u')  *> unicodeHex 4-              <|> (char 'U')  *> unicodeHex 8+    escSeqChar =  char '"'  *> return '"'+              <|> char '\\' *> return '\\'+              <|> char '/'  *> return '/'+              <|> char 'b'  *> return '\b'+              <|> char 't'  *> return '\t'+              <|> char 'n'  *> return '\n'+              <|> char 'f'  *> return '\f'+              <|> char 'r'  *> return '\r'+              <|> char 'u'  *> unicodeHex 4+              <|> char 'U'  *> unicodeHex 8               <?> "escape character"  @@ -266,7 +267,7 @@     let v = fst . head . readHex $ h     return $ if v <= maxChar then toEnum v else '_'   where-    isHex c = (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')+    isHex = or . sequence [isDigit, isAsciiUpper, isAsciiLower]     maxChar = fromEnum (maxBound :: Char)  @@ -281,8 +282,8 @@ skipBlanks :: (TomlM m) => Parser m () skipBlanks = skipMany blank   where-    blank   = try ((some $ satisfy isSpc) >> return ()) <|> comment <|> (void eol)-    comment = char '#' >> (many $ (noneOf ("\n" :: String))) >> return ()+    blank   = void (some (satisfy isSpc)) <|> comment <|> void eol+    comment = char '#' >> void (many $ noneOf ("\n" :: String))   -- | Results in 'True' for whitespace chars, tab or space, according to spec.
src/Text/Toml/Types.hs view
@@ -26,8 +26,8 @@ import           Control.Monad.State       (State) import           Control.Monad.State.Class (MonadState, get, modify) import           Control.Monad.Trans       (lift)-import           Data.HashMap.Strict       (HashMap)-import qualified Data.HashMap.Strict       as M+import           Data.HashMap.Lazy         (HashMap)+import qualified Data.HashMap.Lazy         as M import           Data.Int                  (Int64) import           Data.List                 (intersect) import           Data.Set                  (Set)