packages feed

hpack 0.21.0 → 0.21.1

raw patch · 4 files changed

+49/−6 lines, 4 filesdep +scientificPVP ok

version bump matches the API change (PVP)

Dependencies added: scientific

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+## Changes in 0.21.1+  - Allow dependency constraints to be numbers (see #234)+ ## Changes in 0.21.0   - Accept section-specific fields in conditionals (see #175, thanks to Scott     Fleischman)
hpack.cabal view
@@ -1,11 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+-- This file has been generated from package.yaml by hpack version 0.21.0. -- -- see: https://github.com/sol/hpack ----- hash: db045f3697ddf50f10677f67652465713155419437cab6c893deede5a3330f31+-- hash: e632b2c7492b7b1a42a6c95bdf1b94a5a800b10cc81d785ee085456a5ef719c1  name:           hpack-version:        0.21.0+version:        0.21.1 synopsis:       An alternative format for Haskell packages description:    See README at <https://github.com/sol/hpack#readme> category:       Development@@ -41,6 +41,7 @@     , directory     , filepath     , pretty+    , scientific     , text     , transformers     , unordered-containers@@ -83,6 +84,7 @@     , filepath     , hpack     , pretty+    , scientific     , text     , transformers     , unordered-containers@@ -117,6 +119,7 @@     , interpolate     , mockery >=0.3     , pretty+    , scientific     , temporary     , text     , transformers
src/Hpack/Dependency.hs view
@@ -20,6 +20,7 @@ import qualified Distribution.Version as D import           Data.Map.Lazy (Map) import qualified Data.Map.Lazy as Map+import           Data.Scientific import           Data.Aeson.Types import           Control.Applicative import           GHC.Exts@@ -65,11 +66,21 @@   parseJSON v = case v of     Null -> return AnyVersion     Object _ -> SourceDependency <$> parseJSON v+    Number n -> return (scientificToDependencyVersion n)     String s -> parseVersionRange ("== " ++ input) <|> parseVersionRange input       where         input = T.unpack s -    _ -> typeMismatch "Null, Object, or String" v+    _ -> typeMismatch "Null, Object, Number, or String" v++scientificToDependencyVersion :: Scientific -> DependencyVersion+scientificToDependencyVersion n = VersionRange ("==" ++ version)+  where+    version = formatScientific Fixed (Just decimalPlaces) n+    decimalPlaces+      | e < 0 = abs e+      | otherwise = 0+    e = base10Exponent n  instance FromJSON SourceDependency where   parseJSON = withObject "SourceDependency" (\o -> let
test/Hpack/DependencySpec.hs view
@@ -109,8 +109,34 @@          it "rejects invalid values" $ do           [i|-            hpack: 23-          |] `parsesAs` Left "Error in $.hpack: expected Null, Object, or String, encountered Number"+            hpack: []+          |] `parsesAs` Left "Error in $.hpack: expected Null, Object, Number, or String, encountered Array"++        context "when the constraint is a Number" $ do+          it "accepts 1" $ do+            [i|+              hpack: 1+            |] `parsesAs` Right [("hpack", VersionRange "==1")]++          it "accepts 1.0" $ do+            [i|+              hpack: 1.0+            |] `parsesAs` Right [("hpack", VersionRange "==1.0")]++          it "accepts 0.11" $ do+            [i|+              hpack: 0.11+            |] `parsesAs` Right [("hpack", VersionRange "==0.11")]++          it "accepts 0.110" $ do+            [i|+              hpack: 0.110+            |] `parsesAs` Right [("hpack", VersionRange "==0.110")]++          it "accepts 1e2" $ do+            [i|+              hpack: 1e2+            |] `parsesAs` Right [("hpack", VersionRange "==100")]          context "when the constraint is a String" $ do           it "accepts version ranges" $ do