packages feed

liblastfm 0.5.0 → 0.5.1

raw patch · 6 files changed

+30/−22 lines, 6 filesdep −contravariantdep −voidPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: contravariant, void

API changes (from Hackage documentation)

- Network.Lastfm.Internal: instance Contravariant (Request f)
+ Network.Lastfm.Response: closeConnection :: Connection -> IO ()
+ Network.Lastfm.Response: newConnection :: IO Connection
- Network.Lastfm.Internal: coerce :: (Contravariant f, Functor f) => f a -> f b
+ Network.Lastfm.Internal: coerce :: Request f a -> Request f b

Files

CHANGELOG.markdown view
@@ -1,3 +1,10 @@+0.5.1+=====++  * Updated documentation to reflect the changes in `0.5.0`.++  * Dropped `void` and `contravariant` dependencies+ 0.5.0 ===== 
README.markdown view
@@ -55,8 +55,9 @@  To send constructed request use `lastfm`: -    >>> lastfm $ Tag.search <*> tag "russian-folk" <* limit 10 <*> apiKey "29effec263316a1f8a97f753caaa83e0" <* json-    Just (Object fromList [("results",Object fromList [("tagmatches", ...+    >>> con <- newConnection+    >>> lastfm con $ Tag.search <*> tag "russian-folk" <* limit 10 <*> apiKey "29effec263316a1f8a97f753caaa83e0" <* json+    Right (Object (fromList [("results",Object (fromList [("tagmatches", ...  [Wiki][liblastfm/wiki] describes how to parse responses. 
liblastfm.cabal view
@@ -1,5 +1,5 @@ name:          liblastfm-version:       0.5.0+version:       0.5.1 synopsis:      Lastfm API interface license:       MIT license-file:  LICENSE@@ -41,7 +41,6 @@     , bytestring     , cereal     , containers      >= 0.5-    , contravariant     , crypto-api     , http-client     >= 0.3     , http-client-tls >= 0.2@@ -50,7 +49,6 @@     , pureMD5     , semigroups     , text-    , void     , xml-conduit     >= 1.1   hs-source-dirs:    src@@ -147,7 +145,6 @@     , bytestring     , cereal     , containers-    , contravariant     , crypto-api     , hspec     , hspec-expectations-lens >= 0.3.0.0@@ -159,7 +156,6 @@     , profunctors     , pureMD5     , text-    , void     , xml-conduit     , xml-html-conduit-lens   >= 0.3   hs-source-dirs:
src/Network/Lastfm/Authentication.hs view
@@ -18,13 +18,14 @@ -- >>> import Network.Lastfm -- >>> import Network.Lastfm.Authentication -- >>> :set -XOverloadedStrings--- >>> lastfm $ getToken <*> apiKey "__API_KEY__" <* json--- Just (Object fromList [("token",String "__TOKEN__")])+-- >>> con <- newConnection+-- >>> lastfm con $ getToken <*> apiKey "__API_KEY__" <* json+-- Right (Object (fromList [("token",String "__TOKEN__")])) -- >>> putStrLn . link $ apiKey "__API_KEY__" <* token "__TOKEN__" -- http://www.last.fm/api/auth/?api_key=__API_KEY__&token=__TOKEN__ -- >>> -- Click that link ^^^--- >>> lastfm . sign "__SECRET__" $ getSession <*> token "__TOKEN__" <*> apiKey "__API_KEY__"  <* json--- Just (Object fromList [("session",Object fromList [("name",String "__USER__"),("subscriber",String "0"),("key",String "__SESSION_KEY__")])])+-- >>> lastfm con $ sign "__SECRET__" $ getSession <*> token "__TOKEN__" <*> apiKey "__API_KEY__"  <* json+-- Right (Object (fromList [("session",Object (fromList [("subscriber",String "0"),("key",String "__SESSION_KEY__"),("name",String "__USER__")]))])) module Network.Lastfm.Authentication   ( -- * Helpers     getToken, getSession, getMobileSession
src/Network/Lastfm/Internal.hs view
@@ -29,7 +29,6 @@ import           Control.Applicative import           Data.ByteString (ByteString) import           Data.Foldable (Foldable(..))-import           Data.Functor.Contravariant (Contravariant(..)) import           Data.Map.Strict (Map) import qualified Data.Map.Strict as M import           Data.Monoid@@ -38,7 +37,6 @@ import qualified Data.Text as T import qualified Data.Text.Encoding as T import           Data.Traversable (Traversable(..))-import           Data.Void (absurd) import           Network.URI (escapeURIChar, isUnreserved)  @@ -73,10 +71,6 @@   fmap f (Request x) = Request (fmap f x)   {-# INLINE fmap #-} -instance Contravariant (Request f) where-  contramap f (Request x) = Request (contramap f x)-  {-# INLINE contramap #-}- instance Applicative (Request f) where   pure x = Request (pure x)   Request f <*> Request x = Request (f <*> x)@@ -91,9 +85,8 @@   {-# INLINE traverse #-}  --- | Copypaste from "Control.Lens.Internal.Getter"-coerce :: (Contravariant f, Functor f) => f a -> f b-coerce = fmap absurd . contramap absurd+coerce :: Request f a -> Request f b+coerce (Request (Const x)) = Request (Const x) {-# INLINE coerce #-}  
src/Network/Lastfm/Response.hs view
@@ -13,6 +13,8 @@     -- * Perform requests   , Connection   , withConnection+  , newConnection+  , closeConnection   , lastfm   , lastfm_   , Supported@@ -29,7 +31,7 @@   ) where  import           Control.Applicative-import           Control.Exception (SomeException(..), Exception(..), catch)+import           Control.Exception (SomeException(..), Exception(..), bracket, catch) import           Crypto.Classes (hash') import           Data.Aeson ((.:), Value(..), decode) import           Data.Aeson.Types (parseMaybe)@@ -207,7 +209,15 @@ -- | Creating an HTTPS connection manager is expensive; it's advised to use -- a single 'Connection' for all communications with last.fm withConnection :: (Connection -> IO a) -> IO a-withConnection f = Http.withManager Http.tlsManagerSettings (f . Connection)+withConnection = bracket newConnection closeConnection++-- | Create a 'Connection'+newConnection :: IO Connection+newConnection = Connection <$> Http.newManager Http.tlsManagerSettings++-- | Close a 'Connection'+closeConnection :: Connection -> IO ()+closeConnection (Connection man) = Http.closeManager man  -- | Perform the 'Request' and parse the response lastfm :: Supported f r => Connection -> Request f Ready -> IO (Either LastfmError r)