Safe Haskell | None |
---|---|
Language | Haskell2010 |
Request sending and Response parsing
- newtype Secret = Secret Text
- sign :: Secret -> Request f Sign -> Request f Ready
- data Connection
- withConnection :: (Connection -> IO a) -> IO a
- newConnection :: IO Connection
- closeConnection :: Connection -> IO ()
- lastfm :: Supported f r => Connection -> Request f Ready -> IO (Either LastfmError r)
- lastfm_ :: Supported f r => Connection -> Request f Ready -> IO (Either LastfmError ())
- class Supported f r | f -> r, r -> f
- data Format
- data LastfmError
- _LastfmBadResponse :: (Choice p, Applicative m, AsLastfmError e) => p ByteString (m ByteString) -> p e (m e)
- _LastfmEncodedError :: (Choice p, Applicative m, AsLastfmError e) => p (Int, Text) (m (Int, Text)) -> p e (m e)
- _LastfmHttpError :: (Choice p, Applicative m, AsLastfmError e) => p HttpException (m HttpException) -> p e (m e)
Compute request signature
The signature is required for every authenticated API request. Basically, every such request appends the md5 footprint of its arguments to the query as described at http://www.last.fm/api/authspec#8
Application secret
Perform requests
data Connection Source
Lastfm connection manager
withConnection :: (Connection -> IO a) -> IO a Source
Creating an HTTPS connection manager is expensive; it's advised to use
a single Connection
for all communications with last.fm
newConnection :: IO Connection Source
Create a Connection
closeConnection :: Connection -> IO () Source
Close a Connection
lastfm :: Supported f r => Connection -> Request f Ready -> IO (Either LastfmError r) Source
Perform the Request
and parse the response
lastfm_ :: Supported f r => Connection -> Request f Ready -> IO (Either LastfmError ()) Source
Perform the Request
ignoring any responses
class Supported f r | f -> r, r -> f Source
Supported
provides parsing for the chosen Format
JSON
is parsed to Value
type from aeson, while XML
is parsed to Document
from xml-conduit
prepareRequest, parseResponseBody, parseResponseEncodedError
Response format: either JSON or XML
Errors
data LastfmError Source
Different ways last.fm response can be unusable
LastfmBadResponse ByteString | last.fm thinks it responded with something legible, but it really isn't |
LastfmEncodedError Int Text | last.fm error code and message string |
LastfmHttpError HttpException | wrapped http-conduit exception |
Eq LastfmError | Admittedly, this isn't the best |
Show LastfmError | |
Exception LastfmError | |
Typeable * LastfmError |
_LastfmBadResponse :: (Choice p, Applicative m, AsLastfmError e) => p ByteString (m ByteString) -> p e (m e) Source
This is a Prism'
in disguiseLastfmError
ByteString
_LastfmEncodedError :: (Choice p, Applicative m, AsLastfmError e) => p (Int, Text) (m (Int, Text)) -> p e (m e) Source
This is a Prism'
in disguiseLastfmError
(Int
, String
)
_LastfmHttpError :: (Choice p, Applicative m, AsLastfmError e) => p HttpException (m HttpException) -> p e (m e) Source
This is a Prism'
in disguiseLastfmError
HttpException