htoml-megaparsec 2.0.0.2 → 2.1.0.0
raw patch · 7 files changed
+15/−51 lines, 7 filesdep −hspecdep ~megaparsecsetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies removed: hspec
Dependency ranges changed: megaparsec
API changes (from Hackage documentation)
- Text.Toml.Parser: anyStr :: (TomlM m) => Parser m Node
- Text.Toml.Parser: anyStr' :: (TomlM m) => Parser m Text
- Text.Toml.Parser: array :: (TomlM m) => Parser m Node
- Text.Toml.Parser: arrayOf :: (TomlM m) => Parser m Node -> Parser m Node
- Text.Toml.Parser: assignment :: (TomlM m) => Parser m (Text, Node)
- Text.Toml.Parser: basicStr :: (TomlM m) => Parser m Text
- Text.Toml.Parser: boolean :: (TomlM m) => Parser m Node
- Text.Toml.Parser: datetime :: (TomlM m) => Parser m Node
- Text.Toml.Parser: escSeq :: (TomlM m) => Parser m Char
- Text.Toml.Parser: float :: (TomlM m) => Parser m Node
- Text.Toml.Parser: headerValue :: (TomlM m) => Parser m [Text]
- Text.Toml.Parser: inlineTable :: (TomlM m) => Parser m (Either (Set (ErrorFancy Void)) Node)
- Text.Toml.Parser: integer :: (TomlM m) => Parser m Node
- Text.Toml.Parser: isSpc :: Char -> Bool
- Text.Toml.Parser: literalStr :: (TomlM m) => Parser m Text
- Text.Toml.Parser: maybeDupe :: Ord a => [a] -> Maybe a
- Text.Toml.Parser: multiBasicStr :: (TomlM m) => Parser m Text
- Text.Toml.Parser: multiLiteralStr :: (TomlM m) => Parser m Text
- Text.Toml.Parser: namedSection :: (TomlM m) => Parser m ([Text], Node)
- Text.Toml.Parser: parseOnly :: Parser Toml a -> Text -> Either TomlError a
- Text.Toml.Parser: signed :: (Num a, TomlM m) => Parser m a -> Parser m a
- Text.Toml.Parser: skipBlanks :: (TomlM m) => Parser m ()
- Text.Toml.Parser: table :: (TomlM m) => Parser m Table
- Text.Toml.Parser: tableArrayHeader :: (TomlM m) => Parser m [Text]
- Text.Toml.Parser: tableHeader :: (TomlM m) => Parser m [Text]
- Text.Toml.Parser: tomlDoc :: (TomlM m) => Parser m Table
- Text.Toml.Parser: type TomlError = ParseError (Token Text) Void
- Text.Toml.Parser: unicodeHex :: (TomlM m) => Int -> Parser m Char
- Text.Toml.Parser: value :: (TomlM m) => Parser m (Either (Set (ErrorFancy Void)) Node)
- Text.Toml.Types: Explicit :: Explicitness
- Text.Toml.Types: Implicit :: Explicitness
- Text.Toml.Types: VArray :: VArray -> Node
- Text.Toml.Types: VBoolean :: Bool -> Node
- Text.Toml.Types: VDatetime :: UTCTime -> Node
- Text.Toml.Types: VFloat :: Double -> Node
- Text.Toml.Types: VInteger :: Int64 -> Node
- Text.Toml.Types: VString :: Text -> Node
- Text.Toml.Types: VTArray :: VTArray -> Node
- Text.Toml.Types: VTable :: Table -> Node
- Text.Toml.Types: data Explicitness
- Text.Toml.Types: data Node
- Text.Toml.Types: emptyTable :: Table
- Text.Toml.Types: insert :: (TomlM m) => Explicitness -> ([Text], Node) -> Table -> Parser m Table
- Text.Toml.Types: instance Control.DeepSeq.NFData Text.Toml.Types.Node
- Text.Toml.Types: instance GHC.Classes.Eq Text.Toml.Types.Explicitness
- Text.Toml.Types: instance GHC.Classes.Eq Text.Toml.Types.Node
- Text.Toml.Types: instance GHC.Generics.Generic Text.Toml.Types.Node
- Text.Toml.Types: instance GHC.Show.Show Text.Toml.Types.Explicitness
- Text.Toml.Types: instance GHC.Show.Show Text.Toml.Types.Node
- Text.Toml.Types: isExplicit :: Explicitness -> Bool
- Text.Toml.Types: throwParser :: (MonadPlus m, Alternative m, Ord e, MonadParsec e s m) => String -> m a
- Text.Toml.Types: type Parser m a = (MonadState (Set [Text]) m) => ParsecT Void Text m a
- Text.Toml.Types: type Table = HashMap Text Node
- Text.Toml.Types: type Toml = State (Set [Text])
- Text.Toml.Types: type TomlM m = (MonadState (Set [Text]) m)
- Text.Toml.Types: type VArray = Vector Node
- Text.Toml.Types: type VTArray = Vector Table
+ Text.Toml: VArray :: VArray -> Node
+ Text.Toml: VBoolean :: Bool -> Node
+ Text.Toml: VDatetime :: UTCTime -> Node
+ Text.Toml: VFloat :: Double -> Node
+ Text.Toml: VInteger :: Int64 -> Node
+ Text.Toml: VString :: Text -> Node
+ Text.Toml: VTArray :: VTArray -> Node
+ Text.Toml: VTable :: Table -> Node
+ Text.Toml: data Node
+ Text.Toml: parseErrorPretty :: (Stream s, ShowErrorComponent e) => ParseError s e -> String
+ Text.Toml: parseTomlDoc :: FilePath -> Text -> Either TomlError Table
+ Text.Toml: type Table = HashMap Text Node
Files
- Setup.hs +0/−2
- htoml-megaparsec.cabal +3/−5
- internal/Text/Megaparsec/CharRW.hs +5/−5
- internal/Text/Toml/Parser.hs +5/−16
- internal/Text/Toml/Types.hs +2/−4
- test/Test.hs +0/−3
- test/Text/TomlSpec.hs +0/−16
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
htoml-megaparsec.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: htoml-megaparsec-version: 2.0.0.2+version: 2.1.0.0 license: BSD3 license-file: LICENSE copyright: (c) 2013-2016 Cies Breijs, 2017-2018 Vanessa McHale@@ -35,7 +35,7 @@ hs-source-dirs: src default-language: Haskell2010 other-extensions: ConstraintKinds DeriveGeneric FlexibleContexts- OverloadedStrings RankNTypes GADTs MonoLocalBinds+ OverloadedStrings RankNTypes GADTs MonoLocalBinds DeriveAnyClass ghc-options: -Wall build-depends: base >=4.8 && <5,@@ -62,7 +62,7 @@ build-depends: base >=4.7 && <5, containers >=0.5,- megaparsec >=6.0.0,+ megaparsec >=7.0.0, unordered-containers >=0.2, vector >=0.10, text >=1.0 && <2,@@ -85,14 +85,12 @@ BurntSushi JSON Text.Toml.Parser.Spec- Text.TomlSpec default-language: Haskell2010 ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.9 && <5, megaparsec -any, containers -any,- hspec -any, unordered-containers -any, vector -any, aeson -any,
internal/Text/Megaparsec/CharRW.hs view
@@ -6,14 +6,14 @@ ) where import Data.Foldable (Foldable)-import Text.Megaparsec-import Text.Megaparsec.Char as X hiding (noneOf, oneOf)-import qualified Text.Megaparsec.Char as Megaparsec+import Text.Megaparsec hiding (noneOf, oneOf)+import qualified Text.Megaparsec as Megaparsec+import Text.Megaparsec.Char as X {-# RULES-"noneOf/char" forall c. noneOf [c] = char 'c'+"noneOf/char" forall c. noneOf [c] = anySingleBut 'c' "noneOf/satsify" forall c c'. noneOf [c, c'] = satisfy (\x -> x /= c && x /= c')-"oneOf/notChar" forall c. oneOf [c] = notChar 'c'+"oneOf/notChar" forall c. oneOf [c] = char 'c' "oneOf/satisfy" forall c c'. oneOf [c, c'] = satisfy (\x -> x == c || x == c') #-}
internal/Text/Toml/Parser.hs view
@@ -20,11 +20,11 @@ import qualified Data.Vector as V import Data.Void import Numeric (readHex)-import Text.Megaparsec+import Text.Megaparsec hiding (noneOf, oneOf) import Text.Megaparsec.CharRW import Text.Toml.Types -type TomlError = ParseError (Token Text) Void+type TomlError = ParseErrorBundle Text Void -- | Convenience function for the test suite and GHCI. parseOnly :: Parser Toml a -> Text -> Either TomlError a@@ -142,14 +142,12 @@ boolean = VBoolean <$> ( string "true" $> True <|> string "false" $> False ) - anyStr :: (TomlM m) => Parser m Node anyStr = VString <$> anyStr' anyStr' :: (TomlM m) => Parser m Text anyStr' = try multiBasicStr <|> try basicStr <|> try multiLiteralStr <|> literalStr - basicStr :: (TomlM m) => Parser m Text basicStr = between dQuote dQuote (pack <$> many strChar) where@@ -174,24 +172,21 @@ where sQuote = char '\'' - multiLiteralStr :: (TomlM m) => Parser m Text-multiLiteralStr = openSQuote3 *> (pack <$> manyTill anyChar sQuote3)+multiLiteralStr = openSQuote3 *> (pack <$> manyTill anySingle sQuote3) where -- | Parse the a tripple-single quote, with possibly a newline attached openSQuote3 = try (sQuote3 <* char '\n') <|> sQuote3 -- | Parse tripple-single quotes sQuote3 = try . count 3 . char $ '\'' - datetime :: (TomlM m) => Parser m Node datetime = do- d <- manyTill anyChar (char 'Z')+ d <- manyTill anySingle (char 'Z') let mt = parseTimeM True defaultTimeLocale (iso8601DateFormat $ Just "%X") d case mt of Just t -> return $ VDatetime t Nothing -> throwParser "parsing datetime failed" - -- | Attoparsec 'double' parses scientific "e" notation; reimplement according to Toml spec. float :: (TomlM m) => Parser m Node float = VFloat <$> do@@ -206,7 +201,6 @@ u <- uintStr return . join $ s : [u] - integer :: (TomlM m) => Parser m Node integer = VInteger <$> signed (read <$> uintStr) where@@ -225,7 +219,6 @@ separatedValues = sepEndBy (skipBlanks *> try p <* skipBlanks) comma <* skipBlanks comma = skipBlanks >> char ',' >> skipBlanks - -- | Parser for escape sequences. escSeq :: (TomlM m) => Parser m Char escSeq = char '\\' *> escSeqChar@@ -242,7 +235,6 @@ <|> char 'U' *> unicodeHex 8 <?> "escaped character" - -- | Parser for unicode hexadecimal values of representation length 'n'. unicodeHex :: (TomlM m) => Int -> Parser m Char unicodeHex n = do@@ -253,21 +245,18 @@ -- isHex x = or . sequence [isDigit, isAsciiUpper, isAsciiLower] maxChar = fromEnum (maxBound :: Char) - -- | Parser for signs (a plus or a minus). signed :: (Num a, TomlM m) => Parser m a -> Parser m a signed p = p <|> (negate <$> (char '-' *> p)) <|> (char '+' *> p) - -- | Parses the (rest of the) line including an EOF, whitespace and comments. skipBlanks :: (TomlM m) => Parser m () skipBlanks = skipMany blank where blank = void (some (satisfy isSpc)) <|> comment <|> void eol- comment = char '#' >> void (many $ noneOf ("\n" :: String))-+ comment = char '#' *> void (many $ noneOf ("\n" :: String)) -- | Results in 'True' for whitespace chars, tab or space, according to spec. isSpc :: Char -> Bool
internal/Text/Toml/Types.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-}@@ -69,14 +70,11 @@ | VBoolean Bool | VDatetime UTCTime | VArray VArray- deriving (Eq, Show, Generic)--instance NFData Node where+ deriving (Show, Eq, Generic, NFData) -- | To mark whether or not a 'Table' has been explicitly defined. -- See: https://github.com/toml-lang/toml/issues/376 data Explicitness = Explicit | Implicit- deriving (Eq, Show) -- | Convenience function to get a boolean value. isExplicit :: Explicitness -> Bool
test/Test.hs view
@@ -2,14 +2,11 @@ import Test.Tasty (defaultMain, testGroup) import qualified BurntSushi-import Test.Hspec import Text.Toml.Parser.Spec-import Text.TomlSpec main :: IO () main = do- hspec hspecTests parserSpec <- tomlParserSpec bsTests <- BurntSushi.tests
− test/Text/TomlSpec.hs
@@ -1,16 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}--module Text.TomlSpec (hspecTests) where--import Data.List.NonEmpty-import qualified Data.Set as Set-import Test.Hspec-import Text.Megaparsec-import Text.Toml--hspecTests :: Spec-hspecTests =- describe "parser" $- it "should not parse re-assignment of key" $ do- let actual = parseTomlDoc "noSrc" "q={k=42, k=43}\nd=str"- actual `shouldBe` Left (FancyError (SourcePos "noSrc" (mkPos 1) (mkPos 15) :| []) (Set.fromList [ErrorFail "Cannot redefine key k"]))