packages feed

http-api-data 0.6.2 → 0.6.3

raw patch · 4 files changed

+30/−8 lines, 4 filesdep −HUnitdep −transformers

Dependencies removed: HUnit, transformers

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+0.6.3++* Add To/FromForm instances for () and Void+ 0.6.2  * Support GHC-9.12
http-api-data.cabal view
@@ -1,6 +1,6 @@ cabal-version:   1.12 name:            http-api-data-version:         0.6.2+version:         0.6.3  synopsis:        Converting to/from HTTP API data like URL pieces, headers and query parameters. category:        Web@@ -47,7 +47,6 @@                    , bytestring            >= 0.10.8.2 && < 0.13                    , containers            >= 0.6.0.1  && < 0.8                    , text                  >= 1.2.3.0  && < 1.3 || >=2.0 && <2.2-                   , transformers          >= 0.5.6.2  && < 0.7      -- other-dependencies     build-depends:@@ -94,8 +93,7 @@                    , unordered-containers                    , uuid-types -    build-depends:   HUnit                >= 1.6.0.0  && <1.7-                   , hspec                >= 2.7.1    && <2.12+    build-depends:   hspec                >= 2.7.1    && <2.12                    , QuickCheck           >= 2.13.1   && <2.16                    , quickcheck-instances >= 0.3.25.2 && <0.4 
src/Web/Internal/FormUrlEncoded.hs view
@@ -49,7 +49,7 @@                                              UTCTime, ZonedTime) import           Data.Time.Calendar.Month.Compat (Month) import           Data.Time.Calendar.Quarter.Compat (Quarter, QuarterOfYear (..))-import           Data.Void                  (Void)+import           Data.Void                  (Void, absurd) import           Data.Word                  (Word16, Word32, Word64, Word8) import           GHC.Exts                   (Constraint, IsList (..)) import           GHC.Generics@@ -267,6 +267,16 @@  instance ToForm Form where toForm = id +-- |+--+-- @since 0.6.3+instance ToForm Void where toForm = absurd++-- |+--+-- @since 0.6.3+instance ToForm () where toForm _ = Form HashMap.empty+ instance (ToFormKey k, ToHttpApiData v) => ToForm [(k, v)] where   toForm = fromList . map (toFormKey *** toQueryParam) @@ -412,6 +422,16 @@   fromForm = genericFromForm defaultFormOptions  instance FromForm Form where fromForm = pure++-- |+--+-- @since 0.6.3+instance FromForm Void where fromForm _ = Left "fromForm: Void"++-- |+--+-- @since 0.6.3+instance FromForm () where fromForm _ = Right ()  -- | _NOTE:_ this conversion is unstable and may result in different key order (but not values). instance (FromFormKey k, FromHttpApiData v) => FromForm [(k, v)] where
test/Web/Internal/FormUrlEncodedSpec.hs view
@@ -39,12 +39,12 @@      it "is the right inverse of ToForm" $ property $ \x (y :: Int) -> do       let f1 = fromList [("rec1", x), ("rec2", toQueryParam y)]-          Right r1 = fromForm f1 :: Either Text SimpleRec-      toForm r1 `shouldBe` f1+          r1 = fromForm f1 :: Either Text SimpleRec+      fmap toForm r1 `shouldBe` Right f1      it "returns the underlying error" $ do       let f = fromList [("rec1", "anything"), ("rec2", "bad")]-          Left e = fromForm f :: Either Text SimpleRec+          e = either id (const "no error") (fromForm f :: Either Text SimpleRec)       unpack e `shouldContain` "input does not start with a digit"  urlEncoding :: Spec