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 :: MonadIO m => (Connection -> m a) -> m a
- newConnection :: MonadIO m => m Connection
- 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 :: MonadIO m => (Connection -> m a) -> m a Source
Creating an HTTPS connection manager is expensive; it's advised to use
a single Connection
for all communications with last.fm
newConnection :: MonadIO m => m Connection Source
Create a Connection
. Note that there's no need to close the connection manually,
as it will be closed automatically when no longer in use, that is, all the requests have
been processed and it's about to be garbage collected.
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
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 Source | Admittedly, this isn't the best |
Show LastfmError Source | |
Exception LastfmError Source |
_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