packages feed

toml-parser 2.0.0.0 → 2.0.1.0

raw patch · 5 files changed

+28/−15 lines, 5 filesdep ~basedep ~template-haskell

Dependency ranges changed: base, template-haskell

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for toml-parser +## 2.0.1.0++* Added `ToValue UTCTime` and `FromValue UTCTime`. These correspond+  to offset data-times with the timezone translated to UTC.+ ## 2.0.0.0  * Pervasive annotations on the values added to allow for detailed
src/Toml/Schema/FromValue.hs view
@@ -55,7 +55,7 @@ import Data.Text (Text) import Data.Text qualified as Text import Data.Text.Lazy qualified-import Data.Time (ZonedTime, LocalTime, Day, TimeOfDay)+import Data.Time (ZonedTime, LocalTime, Day, TimeOfDay, UTCTime, zonedTimeToUTC) import Data.Word (Word8, Word16, Word32, Word64) import Numeric.Natural (Natural) import Toml.Schema.Matcher@@ -243,6 +243,11 @@ -- | Matches offset date-time literals instance FromValue ZonedTime where     fromValue (ZonedTime' _ x) = pure x+    fromValue v = typeError "offset date-time" v++-- | Matches offset date-time literals and converts to UTC+instance FromValue UTCTime where+    fromValue (ZonedTime' _ x) = pure (zonedTimeToUTC x)     fromValue v = typeError "offset date-time" v  -- | Matches local date-time literals
src/Toml/Schema/ToValue.hs view
@@ -39,7 +39,7 @@ import Data.Text (Text) import Data.Text qualified as Text import Data.Text.Lazy qualified-import Data.Time (Day, TimeOfDay, LocalTime, ZonedTime)+import Data.Time (Day, TimeOfDay, LocalTime, ZonedTime, UTCTime, utcToZonedTime, utc) import Data.Word (Word8, Word16, Word32, Word64) import Numeric.Natural (Natural) import Toml.Semantics@@ -163,6 +163,7 @@ instance ToValue TimeOfDay where toValue = TimeOfDay instance ToValue LocalTime where toValue = LocalTime instance ToValue ZonedTime where toValue = ZonedTime+instance ToValue UTCTime   where toValue = ZonedTime . utcToZonedTime utc instance ToValue Day       where toValue = Day instance ToValue Integer   where toValue = Integer instance ToValue Natural   where toValue = Integer . fromIntegral
test/TomlSpec.hs view
@@ -12,7 +12,6 @@ -} module TomlSpec (spec) where -import Data.Map (Map) import Data.Map qualified as Map import Data.Text (Text) import Data.Time (Day)@@ -314,9 +313,9 @@           Right (table [             "flt1" .= Double 1.0,             "flt2" .= Double 3.1415,-            "flt3" .= Double (-0.01),-            "flt4" .= Double 5e22,-            "flt5" .= Double 1e06,+            "flt3" .= Double (-1.0e-2),+            "flt4" .= Double 4.9999999999999996e22,+            "flt5" .= Double 1000000.0,             "flt6" .= Double (-2.0e-2),             "flt7" .= Double 6.626e-34,             "flt8" .= Double 224617.445991228,@@ -325,14 +324,17 @@             "sf3"  .= Double (-1/0)])          it "parses nan correctly" $-          decode [quoteStr|+          let checkNaN (Double' _ x) = isNaN x+              checkNaN _         = False+          in+          parse [quoteStr|             # not a number             sf4 = nan  # actual sNaN/qNaN encoding is implementation-specific             sf5 = +nan # same as `nan`             sf6 = -nan # valid, actual encoding is implementation-specific|]           `shouldSatisfy` \case-            Success _ t -> all isNaN (t :: Map Text Double)-            Failure{} -> False+            Left{} -> False+            Right (MkTable x) -> all (checkNaN . snd) x          -- code using Numeric.readFloat can use significant         -- resources. this makes sure this doesn't start happening
toml-parser.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               toml-parser-version:            2.0.0.0+version:            2.0.1.0 synopsis:           TOML 1.0.0 parser description:     TOML parser using generated lexers and parsers with@@ -13,7 +13,7 @@ copyright:          2023 Eric Mertens category:           Text build-type:         Simple-tested-with:        GHC == {8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.4, 9.8.1}+tested-with:        GHC == {8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.5, 9.8.2, 9.10.1}  extra-doc-files:     ChangeLog.md@@ -71,11 +71,11 @@         Toml.Syntax.ParserUtils     build-depends:         array           ^>= 0.5,-        base            ^>= {4.14, 4.15, 4.16, 4.17, 4.18, 4.19},+        base            ^>= {4.14, 4.15, 4.16, 4.17, 4.18, 4.19, 4.20},         containers      ^>= {0.5, 0.6, 0.7},         prettyprinter   ^>= 1.7,         text            >= 0.2 && < 3,-        time            ^>= {1.9, 1.10, 1.11, 1.12},+        time            ^>= {1.9, 1.10, 1.11, 1.12, 1.14},         transformers    ^>= {0.5, 0.6},     build-tool-depends:         alex:alex       >= 3.2,@@ -96,7 +96,7 @@         base,         containers,         hspec           ^>= {2.10, 2.11},-        template-haskell ^>= {2.16, 2.17, 2.18, 2.19, 2.20, 2.21},+        template-haskell ^>= {2.16, 2.17, 2.18, 2.19, 2.20, 2.21, 2.22},         text,         time,         toml-parser,@@ -128,7 +128,7 @@         base,         toml-parser,         hspec           ^>= {2.10, 2.11},-        template-haskell ^>= {2.16, 2.17, 2.18, 2.19, 2.20, 2.21},+        template-haskell ^>= {2.16, 2.17, 2.18, 2.19, 2.20, 2.21, 2.22},         text,     build-tool-depends:         markdown-unlit:markdown-unlit ^>= {0.5.1, 0.6.0},