Hello community,

here is the log from the commit of package ghc-http-api-data for 
openSUSE:Factory checked in at 2016-06-14 23:08:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-http-api-data (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-http-api-data.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-http-api-data"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-http-api-data/ghc-http-api-data.changes      
2015-12-23 08:49:20.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-http-api-data.new/ghc-http-api-data.changes 
2016-06-14 23:08:27.000000000 +0200
@@ -1,0 +2,6 @@
+Sat Jun 11 11:30:24 UTC 2016 - [email protected]
+
+- update to 0.2.3
+* Add more parser helpers for Bounded Enum types.
+
+-------------------------------------------------------------------

Old:
----
  http-api-data-0.2.2.tar.gz

New:
----
  http-api-data-0.2.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-http-api-data.spec ++++++
--- /var/tmp/diff_new_pack.S2KMz8/_old  2016-06-14 23:08:28.000000000 +0200
+++ /var/tmp/diff_new_pack.S2KMz8/_new  2016-06-14 23:08:28.000000000 +0200
@@ -21,7 +21,7 @@
 %bcond_with tests
 
 Name:           ghc-http-api-data
-Version:        0.2.2
+Version:        0.2.3
 Release:        0
 Summary:        Converting to/from HTTP API data like URL pieces, headers and 
query parameters
 License:        BSD-2-Clause

++++++ http-api-data-0.2.2.tar.gz -> http-api-data-0.2.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/http-api-data-0.2.2/CHANGELOG.md 
new/http-api-data-0.2.3/CHANGELOG.md
--- old/http-api-data-0.2.2/CHANGELOG.md        2015-12-10 11:34:51.000000000 
+0100
+++ new/http-api-data-0.2.3/CHANGELOG.md        2016-06-10 02:17:37.000000000 
+0200
@@ -1,3 +1,7 @@
+0.2.3
+---
+* Add more parser helpers for `Bounded` `Enum` types.
+
 0.2.2
 ---
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/http-api-data-0.2.2/Web/HttpApiData/Internal.hs 
new/http-api-data-0.2.3/Web/HttpApiData/Internal.hs
--- old/http-api-data-0.2.2/Web/HttpApiData/Internal.hs 2015-12-10 
11:08:55.000000000 +0100
+++ new/http-api-data-0.2.3/Web/HttpApiData/Internal.hs 2016-06-10 
01:42:14.000000000 +0200
@@ -44,6 +44,9 @@
 #endif
 
 -- | Convert value to HTTP API data.
+--
+-- __WARNING__: Do not derive this using @DeriveAnyClass@ as the generated
+-- instance will loop indefinitely.
 class ToHttpApiData a where
   {-# MINIMAL toUrlPiece | toQueryParam #-}
   -- | Convert to URL path piece.
@@ -59,6 +62,9 @@
   toQueryParam = toUrlPiece
 
 -- | Parse value from HTTP API data.
+--
+-- __WARNING__: Do not derive this using @DeriveAnyClass@ as the generated
+-- instance will loop indefinitely.
 class FromHttpApiData a where
   {-# MINIMAL parseUrlPiece | parseQueryParam #-}
   -- | Parse URL path piece.
@@ -280,9 +286,53 @@
 -- Right Foo
 parseBoundedTextData :: (Show a, Bounded a, Enum a) => Text -> Either Text a
 #endif
-parseBoundedTextData = parseMaybeTextData (flip lookup values . T.toLower)
-  where
-    values = map (showTextData &&& id) [minBound..maxBound]
+parseBoundedTextData = parseBoundedEnumOfI showTextData
+
+-- | Lookup values based on a precalculated mapping of their representations.
+lookupBoundedEnumOf :: (Bounded a, Enum a, Eq b) => (a -> b) -> b -> Maybe a
+lookupBoundedEnumOf f = flip lookup (map (f &&& id) [minBound..maxBound])
+
+-- | Parse values based on a precalculated mapping of their @'Text'@ 
representation.
+--
+-- >>> parseBoundedEnumOf toUrlPiece "true" :: Either Text Bool
+-- Right True
+--
+-- For case sensitive parser see 'parseBoundedEnumOfI'.
+parseBoundedEnumOf :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either 
Text a
+parseBoundedEnumOf = parseMaybeTextData . lookupBoundedEnumOf
+
+-- | /Case insensitive/.
+--
+-- Parse values case insensitively based on a precalculated mapping
+-- of their @'Text'@ representations.
+--
+-- >>> parseBoundedEnumOfI toUrlPiece "FALSE" :: Either Text Bool
+-- Right False
+--
+-- For case sensitive parser see 'parseBoundedEnumOf'.
+parseBoundedEnumOfI :: (Bounded a, Enum a) => (a -> Text) -> Text -> Either 
Text a
+parseBoundedEnumOfI f = parseBoundedEnumOf (T.toLower . f) . T.toLower
+
+-- | /Case insensitive/.
+--
+-- Parse values case insensitively based on @'ToHttpApiData'@ instance.
+-- Uses @'toUrlPiece'@ to get possible values.
+parseBoundedUrlPiece :: (ToHttpApiData a, Bounded a, Enum a) => Text -> Either 
Text a
+parseBoundedUrlPiece = parseBoundedEnumOfI toUrlPiece
+
+-- | /Case insensitive/.
+--
+-- Parse values case insensitively based on @'ToHttpApiData'@ instance.
+-- Uses @'toQueryParam'@ to get possible values.
+parseBoundedQueryParam :: (ToHttpApiData a, Bounded a, Enum a) => Text -> 
Either Text a
+parseBoundedQueryParam = parseBoundedEnumOfI toQueryParam
+
+-- | Parse values based on @'ToHttpApiData'@ instance.
+-- Uses @'toHeader'@ to get possible values.
+parseBoundedHeader :: (ToHttpApiData a, Bounded a, Enum a) => ByteString -> 
Either Text a
+parseBoundedHeader bs = case lookupBoundedEnumOf toHeader bs of
+  Nothing -> defaultParseError (decodeUtf8 bs)
+  Just x  -> return x
 
 -- | Parse URL piece using @'Read'@ instance.
 --
@@ -442,8 +492,8 @@
   parseUrlPiece _ = Left "Void cannot be parsed!"
 #endif
 
-instance FromHttpApiData Bool     where parseUrlPiece = parseBoundedTextData
-instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedTextData
+instance FromHttpApiData Bool     where parseUrlPiece = parseBoundedUrlPiece
+instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedUrlPiece
 instance FromHttpApiData Double   where parseUrlPiece = runReader rational
 instance FromHttpApiData Float    where parseUrlPiece = runReader rational
 instance FromHttpApiData Int      where parseUrlPiece = parseBounded (signed 
decimal)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/http-api-data-0.2.2/Web/HttpApiData.hs 
new/http-api-data-0.2.3/Web/HttpApiData.hs
--- old/http-api-data-0.2.2/Web/HttpApiData.hs  2015-10-12 18:00:09.000000000 
+0200
+++ new/http-api-data-0.2.3/Web/HttpApiData.hs  2016-06-10 01:42:14.000000000 
+0200
@@ -27,10 +27,17 @@
   toQueryParams,
   parseQueryParams,
 
+  -- * Parsers for @'Bounded'@ @'Enum'@s
+  parseBoundedUrlPiece,
+  parseBoundedQueryParam,
+  parseBoundedHeader,
+  parseBoundedEnumOf,
+  parseBoundedEnumOfI,
+  parseBoundedTextData,
+
   -- * Other helpers
   showTextData,
   readTextData,
-  parseBoundedTextData,
 ) where
 
 import Web.HttpApiData.Internal
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/http-api-data-0.2.2/http-api-data.cabal 
new/http-api-data-0.2.3/http-api-data.cabal
--- old/http-api-data-0.2.2/http-api-data.cabal 2015-12-10 11:34:51.000000000 
+0100
+++ new/http-api-data-0.2.3/http-api-data.cabal 2016-06-10 02:17:37.000000000 
+0200
@@ -1,5 +1,5 @@
 name:            http-api-data
-version:         0.2.2
+version:         0.2.3
 license:         BSD3
 license-file:    LICENSE
 author:          Nickolay Kudasov <[email protected]>
@@ -21,11 +21,11 @@
   default: False
 
 library
-    build-depends:   base             >= 4       && < 5
-                   , text             >= 0.5
+    build-depends:   base               >= 4.6    && < 4.10
+                   , text               >= 0.5
                    , bytestring
                    , time
-                   , time-locale-compat
+                   , time-locale-compat >=0.1.1.0 && <0.2
     if flag(use-text-show)
       cpp-options: -DUSE_TEXT_SHOW
       build-depends: text-show        >= 2


Reply via email to