Hello community,

here is the log from the commit of package ghc-kawhi for openSUSE:Factory 
checked in at 2017-08-31 20:56:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-kawhi (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-kawhi.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-kawhi"

Thu Aug 31 20:56:57 2017 rev:3 rq:513413 version:0.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-kawhi/ghc-kawhi.changes      2017-06-04 
01:54:33.276909504 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-kawhi.new/ghc-kawhi.changes 2017-08-31 
20:56:59.546957350 +0200
@@ -1,0 +2,5 @@
+Thu Jul 27 14:07:44 UTC 2017 - [email protected]
+
+- Update to version 0.3.0.
+
+-------------------------------------------------------------------

Old:
----
  kawhi-0.2.3.tar.gz

New:
----
  kawhi-0.3.0.tar.gz

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

Other differences:
------------------
++++++ ghc-kawhi.spec ++++++
--- /var/tmp/diff_new_pack.ILLYid/_old  2017-08-31 20:57:00.266856202 +0200
+++ /var/tmp/diff_new_pack.ILLYid/_new  2017-08-31 20:57:00.270855639 +0200
@@ -19,7 +19,7 @@
 %global pkg_name kawhi
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.2.3
+Version:        0.3.0
 Release:        0
 Summary:        Stats.NBA.com library
 License:        MIT

++++++ kawhi-0.2.3.tar.gz -> kawhi-0.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/kawhi-0.2.3/changelog.md new/kawhi-0.3.0/changelog.md
--- old/kawhi-0.2.3/changelog.md        2017-04-24 01:04:24.000000000 +0200
+++ new/kawhi-0.3.0/changelog.md        2017-04-23 00:55:23.000000000 +0200
@@ -1,10 +1,18 @@
 # Changelog
 
-## 0.2.3
+## 0.3.0
 
-Add HTTP `Referer` header to all requests. 
+### Summary
 
-*This may not be added versions greater than `0.2.*`, because `0.3.0` allows 
users to independently retrieve data from NBA Stats.*
+Added parse-only APIs.
+
+### API Changes
+
+- `splitRows`
+- `splitRow`
+- `splitRowsGeneric`
+- `splitRowGeneric`
+- `StatsBytes`
 
 ## 0.2.2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/kawhi-0.2.3/kawhi.cabal new/kawhi-0.3.0/kawhi.cabal
--- old/kawhi-0.2.3/kawhi.cabal 2017-04-24 01:04:22.000000000 +0200
+++ new/kawhi-0.3.0/kawhi.cabal 2017-04-23 00:54:07.000000000 +0200
@@ -1,5 +1,5 @@
 name: kawhi
-version: 0.2.3
+version: 0.3.0
 synopsis: stats.NBA.com library
 description: Functions and types for interacting with stats.NBA.com
 homepage: https://github.com/thunky-monk/kawhi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/kawhi-0.2.3/library/Data/NBA/Stats.hs 
new/kawhi-0.3.0/library/Data/NBA/Stats.hs
--- old/kawhi-0.2.3/library/Data/NBA/Stats.hs   2017-04-24 01:04:24.000000000 
+0200
+++ new/kawhi-0.3.0/library/Data/NBA/Stats.hs   2017-04-23 00:55:48.000000000 
+0200
@@ -19,10 +19,14 @@
     -- * Simple API
     getSplitRows,
     getSplitRow,
+    splitRows,
+    splitRow,
 
     -- * Generic API
     getSplitRowsGeneric,
     getSplitRowGeneric,
+    splitRowsGeneric,
+    splitRowGeneric,
 
     -- * Types
     Stats(..),
@@ -32,6 +36,7 @@
     SplitRow,
     StatsPath,
     StatsParameters,
+    StatsBytes,
     StatsError(..),
 ) where
 
@@ -55,6 +60,8 @@
 {- |
     Gets all the rows in a NBA Stats split.
 
+    To retrieve the raw data from NBA Stats independently from parsing, use 
'splitRows'.
+
     When using this function in a custom monad transformer, it may be 
desirable to use the generic version of this function, 'getSplitRowsGeneric', 
instead.
 -}
 getSplitRows ::
@@ -66,8 +73,24 @@
 getSplitRows path splitName params = Except.runExceptT $ getSplitRowsGeneric 
path splitName params
 
 {- |
+    Parses all the rows of an NBA Stats split from abitrary data.
+
+    Alternatively, 'getSplitRows' retrieves the data from NBA Stats before 
parsing.
+
+    To use something other than 'Either' for errors, use the generic version 
of this function, 'splitRowsGeneric', instead.
+-}
+splitRows ::
+    Aeson.FromJSON a
+    => SplitName -- ^ The split name.
+    -> StatsBytes -- ^ The bytes to decode into split rows.
+    -> Either StatsError [a] -- ^ The return value: an action resulting in an 
error or split rows.
+splitRows = splitRowsGeneric
+
+{- |
     Gets a row in a NBA Stats split.
 
+    To retrieve the raw data from NBA Stats independently from parsing, use 
'splitRows'.
+
     When using this function in a custom monad transformer, it may be 
desirable to use the generic version of this function, 'getSplitRowGeneric', 
instead.
 -}
 getSplitRow ::
@@ -81,8 +104,26 @@
 getSplitRow path splitName key value params = Except.runExceptT $ 
getSplitRowGeneric path splitName key value params
 
 {- |
+    Parses a row of an NBA Stats split from abitrary data.
+
+    Alternatively, 'getSplitRow' retrieves the data from NBA Stats before 
parsing.
+
+    To use something other than 'Either' for errors, use the generic version 
of this function, 'splitRowGeneric', instead.
+-}
+splitRow ::
+    (Eq v, Show v, Aeson.FromJSON v, Aeson.FromJSON a)
+    => SplitName -- ^ The split name.
+    -> SplitColumn -- ^ The column name key for a the desired row.
+    -> v -- ^ The expected row value associated with the column name key for a 
the desired row.
+    -> StatsBytes -- ^ The bytes to decode into a split row.
+    -> Either StatsError a -- ^ The return value: an action resulting in an 
error or a split row.
+splitRow = splitRowGeneric
+
+{- |
     Gets all the rows in a NBA Stats split.
 
+    To retrieve the raw data from NBA Stats independently from parsing, use 
'splitRowsGeneric'.
+
     The simpler version of this function, 'getSplitRows', has a concrete 'm'.
 -}
 getSplitRowsGeneric ::
@@ -91,14 +132,27 @@
     -> SplitName -- ^ The split name.
     -> StatsParameters -- ^ The parameters for customizing the stats.
     -> m [a] -- ^ The return value: an action resulting in an error or split 
rows.
-getSplitRowsGeneric path splitName params = do
-    response <- get path params
-    split <- findSplit response splitName
+getSplitRowsGeneric path splitName params = get path params >>= 
splitRowsGeneric splitName
+
+{- |
+    Parses all the rows of an NBA Stats split from abitrary data.
+
+    Alternatively, 'getSplitRowsGeneric' retrieves the data from NBA Stats 
before parsing.
+-}
+splitRowsGeneric ::
+    (Except.MonadError StatsError m, Aeson.FromJSON a)
+    => SplitName -- ^ The split name.
+    -> StatsBytes -- ^ The bytes to decode into split rows.
+    -> m [a] -- ^ The return value: an action resulting in an error or split 
rows.
+splitRowsGeneric splitName bytes = do
+    split <- findSplit splitName bytes
     traverse (parseSplitRow $ columns split) $ rows split
 
 {- |
     Gets a row in an NBA Stats split.
 
+    To retrieve the raw data from NBA Stats independently from parsing, use 
'splitRowGeneric'.
+
     The simpler version of this function, 'getSplitRows', has a concrete 'm'.
 -}
 getSplitRowGeneric ::
@@ -109,9 +163,22 @@
     -> v -- ^ The expected row value associated with the column name key for a 
the desired row.
     -> StatsParameters -- ^ The parameters for customizing the stats.
     -> m a -- ^ The return value: an action resulting in an error or a split 
row.
-getSplitRowGeneric path splitName key value params = do
-    response <- get path params
-    split <- findSplit response splitName
+getSplitRowGeneric path splitName key value params = get path params >>= 
splitRowGeneric splitName key value
+
+{- |
+    Parses a row of an NBA Stats split from abitrary data.
+
+    Alternatively, 'getSplitRowGeneric' retrieves the data from NBA Stats 
before parsing.
+-}
+splitRowGeneric ::
+    (Except.MonadError StatsError m, Eq v, Show v, Aeson.FromJSON v, 
Aeson.FromJSON a)
+    => SplitName -- ^ The split name.
+    -> SplitColumn -- ^ The column name key for a the desired row.
+    -> v -- ^ The expected row value associated with the column name key for a 
the desired row.
+    -> StatsBytes -- ^ The bytes to decode into a split row.
+    -> m a -- ^ The return value: an action resulting in an error or a split 
row.
+splitRowGeneric splitName key value bytes = do
+    split <- findSplit splitName bytes
     keyIndex <- maybe
         (Except.throwError $ SplitColumnNameNotFound $ Text.unpack key)
         return
@@ -196,6 +263,9 @@
 -- | A collection of parameters that customize NBA Stats resources.
 type StatsParameters = [(SBS.ByteString, Maybe SBS.ByteString)]
 
+-- | Bytes representing an NBA Stats resource.
+type StatsBytes = LBS.ByteString
+
 {- |
     An error which may be generated by this library.
 -}
@@ -235,12 +305,12 @@
             Aeson.Success split -> return split
         else Except.throwError $ SplitRowCardinalityInconsistent $ show row
 
-findSplit :: (Except.MonadError StatsError m) => HTTP.Response LBS.ByteString 
-> SplitName -> m Split
-findSplit response splitName = do
+findSplit :: (Except.MonadError StatsError m) => SplitName -> StatsBytes -> m 
Split
+findSplit splitName bytes = do
     stats <- either
         (Except.throwError . StatsResponseDecodeFailure)
         return
-        (Aeson.eitherDecode . HTTP.responseBody $ response)
+        (Aeson.eitherDecode bytes)
     maybe
         (Except.throwError $ SplitNameNotFound $ Text.unpack splitName)
         return
@@ -248,13 +318,15 @@
 
 
 
-get :: (MonadHttp.MonadHttp m, Catch.MonadThrow m) => StatsPath -> 
StatsParameters -> m (HTTP.Response LBS.ByteString)
-get path params =
-    modifyRequest <$> HTTP.parseRequest (Char8.unpack $ 
"http://stats.nba.com/stats/"; <> path)
-    >>= MonadHttp.performRequest
+get :: (MonadHttp.MonadHttp m, Catch.MonadThrow m) => StatsPath -> 
StatsParameters -> m StatsBytes
+get path params = HTTP.responseBody <$> getRequest
     where
+      getRequest =
+        modifyRequest
+        <$> HTTP.parseRequest (Char8.unpack $ "http://stats.nba.com/stats/"; <> 
path)
+        >>= MonadHttp.performRequest
       modifyRequest =
-        HTTP.setRequestHeaders [("Accept-Language","en-us"), ("Accept", 
"application/json"), ("Referer", "stats.nba.com")]
+        HTTP.setRequestHeaders [("Accept-Language","en-us"), ("Accept", 
"application/json")]
         . HTTP.setQueryString params
 
 {- $use


Reply via email to