Safe Haskell | None |
---|---|
Language | Haskell2010 |
Request sending and Response parsing
Synopsis
- 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
Instances
Supported JSON Value Source # | |
Defined in Lastfm.Response prepareRequest :: R JSON -> R JSON | |
Supported XML Document Source # | |
Defined in Lastfm.Response prepareRequest :: R XML -> R 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 |
Instances
Eq LastfmError Source # | Admittedly, this isn't the best |
Defined in Lastfm.Response (==) :: LastfmError -> LastfmError -> Bool # (/=) :: LastfmError -> LastfmError -> Bool # | |
Show LastfmError Source # | |
Defined in Lastfm.Response showsPrec :: Int -> LastfmError -> ShowS # show :: LastfmError -> String # showList :: [LastfmError] -> ShowS # | |
Exception LastfmError Source # | |
Defined in Lastfm.Response |
_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