packages feed

liblastfm 0.0.3.3 → 0.0.3.4

raw patch · 52 files changed

+505/−252 lines, 52 filesdep +HUnitdep +liblastfmdep ~template-haskellPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: HUnit, liblastfm

Dependency ranges changed: template-haskell

API changes (from Hackage documentation)

- Network.Lastfm: boolToString :: Bool -> String
+ Network.Lastfm: AuthenticationFailed :: LastfmError
+ Network.Lastfm: CurlError :: CurlCode -> LastfmError
+ Network.Lastfm: Deprecated :: LastfmError
+ Network.Lastfm: DoesntExist :: LastfmError
+ Network.Lastfm: DoesntExistAgain :: LastfmError
+ Network.Lastfm: InvalidAPIKey :: LastfmError
+ Network.Lastfm: InvalidFormat :: LastfmError
+ Network.Lastfm: InvalidMethod :: LastfmError
+ Network.Lastfm: InvalidMethodSignature :: LastfmError
+ Network.Lastfm: InvalidParameters :: LastfmError
+ Network.Lastfm: InvalidResource :: LastfmError
+ Network.Lastfm: InvalidService :: LastfmError
+ Network.Lastfm: InvalidSessionKey :: LastfmError
+ Network.Lastfm: LoginRequired :: LastfmError
+ Network.Lastfm: NoPeakRadio :: LastfmError
+ Network.Lastfm: NotEnoughContent :: LastfmError
+ Network.Lastfm: NotEnoughFans :: LastfmError
+ Network.Lastfm: NotEnoughMembers :: LastfmError
+ Network.Lastfm: NotEnoughNeighbours :: LastfmError
+ Network.Lastfm: NotForStreaming :: LastfmError
+ Network.Lastfm: OperationFailed :: LastfmError
+ Network.Lastfm: RadioNotFound :: LastfmError
+ Network.Lastfm: RateLimitExceeded :: LastfmError
+ Network.Lastfm: ServiceOffline :: LastfmError
+ Network.Lastfm: SubscribersOnly :: LastfmError
+ Network.Lastfm: SuspendedAPIKey :: LastfmError
+ Network.Lastfm: TemporaryUnavailable :: LastfmError
+ Network.Lastfm: TokenHasNotAuthorized :: LastfmError
+ Network.Lastfm: TrialExpired :: LastfmError
+ Network.Lastfm: UnknownError :: Int -> LastfmError
+ Network.Lastfm: data LastfmError
+ Network.Lastfm: instance Show APIKey
+ Network.Lastfm: instance Show Album
+ Network.Lastfm: instance Show AlbumArtist
+ Network.Lastfm: instance Show Artist
+ Network.Lastfm: instance Show AuthToken
+ Network.Lastfm: instance Show Autocorrect
+ Network.Lastfm: instance Show Bitrate
+ Network.Lastfm: instance Show BuyLinks
+ Network.Lastfm: instance Show ChosenByUser
+ Network.Lastfm: instance Show Context
+ Network.Lastfm: instance Show Country
+ Network.Lastfm: instance Show Description
+ Network.Lastfm: instance Show Discovery
+ Network.Lastfm: instance Show Distance
+ Network.Lastfm: instance Show Duration
+ Network.Lastfm: instance Show End
+ Network.Lastfm: instance Show EndTimestamp
+ Network.Lastfm: instance Show Event
+ Network.Lastfm: instance Show FestivalsOnly
+ Network.Lastfm: instance Show Fingerprint
+ Network.Lastfm: instance Show From
+ Network.Lastfm: instance Show Group
+ Network.Lastfm: instance Show Language
+ Network.Lastfm: instance Show Latitude
+ Network.Lastfm: instance Show Limit
+ Network.Lastfm: instance Show Location
+ Network.Lastfm: instance Show Longitude
+ Network.Lastfm: instance Show Mbid
+ Network.Lastfm: instance Show Message
+ Network.Lastfm: instance Show Method
+ Network.Lastfm: instance Show Metro
+ Network.Lastfm: instance Show Multiplier
+ Network.Lastfm: instance Show Name
+ Network.Lastfm: instance Show Order
+ Network.Lastfm: instance Show Page
+ Network.Lastfm: instance Show Period
+ Network.Lastfm: instance Show Playlist
+ Network.Lastfm: instance Show Public
+ Network.Lastfm: instance Show RTP
+ Network.Lastfm: instance Show RecentTracks
+ Network.Lastfm: instance Show Recipient
+ Network.Lastfm: instance Show Secret
+ Network.Lastfm: instance Show SessionKey
+ Network.Lastfm: instance Show Start
+ Network.Lastfm: instance Show StartTimestamp
+ Network.Lastfm: instance Show Station
+ Network.Lastfm: instance Show Status
+ Network.Lastfm: instance Show StreamId
+ Network.Lastfm: instance Show Tag
+ Network.Lastfm: instance Show TaggingType
+ Network.Lastfm: instance Show Timestamp
+ Network.Lastfm: instance Show Title
+ Network.Lastfm: instance Show To
+ Network.Lastfm: instance Show Token
+ Network.Lastfm: instance Show Track
+ Network.Lastfm: instance Show TrackNumber
+ Network.Lastfm: instance Show UseRecs
+ Network.Lastfm: instance Show User
+ Network.Lastfm: instance Show Username
+ Network.Lastfm: instance Show Venue
+ Network.Lastfm: instance Show Venuename

Files

+ examples/json-auth.hs view
@@ -0,0 +1,51 @@+module Main where++import Control.Applicative (empty)+import System.Exit (ExitCode(ExitFailure), exitSuccess, exitWith)++import qualified Data.ByteString.Lazy as B+import Data.Aeson+import Network.Lastfm+import Test.HUnit+import qualified JSON.Album as Album+import qualified JSON.Artist as Artist+import qualified JSON.Event as Event+import qualified JSON.Library as Library+import qualified JSON.Playlist as Playlist+import qualified JSON.Radio as Radio+import qualified JSON.User as User+import qualified JSON.Track as Track+++main ∷ IO ()+main =+  do keys ← B.readFile "examples/lastfm-keys.json"+     case decode keys of+       Just (Keys ak sk s) →+         do rs ← mapM (runTestTT . TestList . \f → f ak sk s)+              [ Album.private+              , Artist.private+              , Event.private+              , Library.private+              , Playlist.private+              , Radio.private+              , User.private+              , Track.private+              ]+            let fs = sum $ map failures rs+            case fs of+              0 → exitSuccess+              n → exitWith (ExitFailure n)+       Nothing → exitWith (ExitFailure 127)+++data Keys = Keys APIKey SessionKey Secret+++instance FromJSON Keys where+  parseJSON (Object o) =+    do ak ← o .: "APIKey"+       sk ← o .: "SessionKey"+       s ← o .: "Secret"+       return $ Keys (APIKey ak) (SessionKey sk) (Secret s)+  parseJSON _ = empty
+ examples/json-no-auth.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE UnicodeSyntax #-}+module Main where++import System.Exit (ExitCode(ExitFailure), exitSuccess, exitWith)++import Test.HUnit+import qualified JSON.Album as Album+import qualified JSON.Artist as Artist+import qualified JSON.Chart as Chart+import qualified JSON.Event as Event+import qualified JSON.Geo as Geo+import qualified JSON.Group as Group+import qualified JSON.Library as Library+import qualified JSON.Radio as Radio+import qualified JSON.Tag as Tag+import qualified JSON.Tasteometer as Tasteometer+import qualified JSON.Track as Track+import qualified JSON.Venue as Venue+import qualified JSON.User as User+++main ∷ IO ()+main =+  do rs ← mapM (runTestTT . TestList)+       [ Album.public+       , Artist.public+       , Chart.public+       , Event.public+       , Geo.public+       , Group.public+       , Library.public+       , Radio.public+       , Tag.public+       , Tasteometer.public+       , Track.public+       , Venue.public+       , User.public+       ]+     let fs = sum $ map failures rs+     case fs of+       0 → exitSuccess+       n → exitWith (ExitFailure n)
liblastfm.cabal view
@@ -1,20 +1,33 @@-Name: liblastfm-Version: 0.0.3.3-Synopsis: Wrapper to Lastfm API-License: MIT-License-file: LICENSE-Author: Matvey Aksenov, Dmitry Malikov-Maintainer: Matvey Aksenov <matvey.aksenov@gmail.com>-Category: Network APIs-Description: Simple but complete wrapper to Lastfm API. Can send some stuff and receive reponses from Lastfm. JSON/XML parsing is an exercise for the user.-Cabal-Version: >= 1.6-Build-Type: Simple-Extra-Source-Files: docs/*.docs+name: liblastfm+version: 0.0.3.4+synopsis: Wrapper to Lastfm API+license: MIT+license-file: LICENSE+author: Matvey Aksenov, Dmitry Malikov+maintainer: Matvey Aksenov <matvey.aksenov@gmail.com>+category: Network APIs+description: Simple but complete wrapper to Lastfm API. Can send some stuff and receive reponses from Lastfm. JSON/XML parsing is an exercise for the user.+cabal-version: >= 1.9.2+build-type: Simple+extra-source-files: docs/*.docs -Library-  Build-Depends: base >= 3 && < 5, template-haskell >= 2.5 && < 2.8, bytestring == 0.9.*, mtl == 2.*, curl == 1.3.7, pureMD5 == 2.1.*, urlencoded == 0.3.*, aeson == 0.6.*, xml == 1.3.12, utf8-string == 0.3.*-  HS-Source-Dirs: src-  Exposed-Modules: Network.Lastfm+flag test-authentication+  description: Test authentication dependent LastFM API too.+  default: False++library+  build-depends: base >= 3 && < 5,+                 template-haskell,+                 bytestring == 0.9.*,+                 mtl == 2.*,+                 curl == 1.3.7,+                 pureMD5 == 2.1.*,+                 urlencoded == 0.3.*,+                 aeson == 0.6.*,+                 xml == 1.3.12,+                 utf8-string == 0.3.*+  hs-source-dirs: src+  exposed-modules: Network.Lastfm                    Network.Lastfm.JSON.Album                    Network.Lastfm.JSON.Artist                    Network.Lastfm.JSON.Auth@@ -45,9 +58,11 @@                    Network.Lastfm.XML.Track                    Network.Lastfm.XML.User                    Network.Lastfm.XML.Venue-  Other-Modules:   Network.Lastfm.Internal+  other-modules:   Network.Lastfm.Internal                    Network.Lastfm.TH                    Network.Lastfm.Error+                   Network.Lastfm.JSON+                   Network.Lastfm.XML                    Network.Lastfm.API.Album                    Network.Lastfm.API.Artist                    Network.Lastfm.API.Auth@@ -63,10 +78,40 @@                    Network.Lastfm.API.Track                    Network.Lastfm.API.User                    Network.Lastfm.API.Venue-  Extensions: UnicodeSyntax-  GHC-Options: -Wall+  extensions: UnicodeSyntax+  ghc-options: -Wall                -fno-warn-unused-do-bind-  CPP-Options: -Idocs+               -fno-warn-orphans+  cpp-options: -Idocs++test-suite json-no-authentication+  build-depends: base >= 3 && < 5,+                 aeson == 0.6.*,+                 HUnit == 1.2.4.*,+                 liblastfm+  type: exitcode-stdio-1.0+  main-is: json-no-auth.hs+  hs-source-dirs: examples+  extensions: OverloadedStrings, UnicodeSyntax+  ghc-options: -Wall+               -fno-warn-unused-do-bind+               -fno-warn-orphans++test-suite json-authentication+  build-depends: base >= 3 && < 5,+                 bytestring == 0.9.*,+                 aeson == 0.6.*,+                 HUnit == 1.2.4.*,+                 liblastfm+  type: exitcode-stdio-1.0+  main-is: json-auth.hs+  hs-source-dirs: examples+  extensions: OverloadedStrings, UnicodeSyntax+  ghc-options: -Wall+               -fno-warn-unused-do-bind+               -fno-warn-orphans+  if !flag(test-authentication)+     buildable: False  source-repository head   type:     git
src/Network/Lastfm.hs view
@@ -1,6 +1,72 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}-module Network.Lastfm where+module Network.Lastfm+  ( Lastfm, Response, LastfmError(..)+  , Secret(..)+  , Argument(..)+  , Album(..)+  , AlbumArtist(..)+  , APIKey(..)+  , Artist(..)+  , AuthToken(..)+  , Autocorrect(..)+  , Bitrate(..)+  , ChosenByUser(..)+  , Context(..)+  , Country(..)+  , Description(..)+  , Group(..)+  , Language(..)+  , Latitude(..)+  , Location(..)+  , Longitude(..)+  , Mbid(..)+  , Message(..)+  , Method(..)+  , Metro(..)+  , Multiplier(..)+  , Name(..)+  , Order(..)+  , Period(..)+  , Recipient(..)+  , SessionKey(..)+  , Status(..)+  , Station(..)+  , StreamId(..)+  , Tag(..)+  , TaggingType(..)+  , Title(..)+  , Token(..)+  , Track(..)+  , User(..)+  , Username(..)+  , Value(..)+  , Venuename(..)+  , BuyLinks(..)+  , Discovery(..)+  , FestivalsOnly(..)+  , Public(..)+  , RecentTracks(..)+  , RTP(..)+  , UseRecs(..)+  , Distance(..)+  , Duration(..)+  , Event(..)+  , Limit(..)+  , Page(..)+  , Playlist(..)+  , TrackNumber(..)+  , Venue(..)+  , End(..)+  , EndTimestamp(..)+  , Fingerprint(..)+  , From(..)+  , Start(..)+  , StartTimestamp(..)+  , Timestamp(..)+  , To(..)+  , simple+  ) where  import Control.Applicative ((<$>), empty) import Control.Monad (liftM)@@ -19,7 +85,7 @@ type Response = ByteString  -newtype Secret = Secret String+newtype Secret = Secret String deriving Show   $(newtypes "String" ["Album", "AlbumArtist", "APIKey", "Artist", "AuthToken",@@ -32,13 +98,13 @@ $(newtypes "Integer" ["End", "EndTimestamp", "Fingerprint", "From", "Start", "StartTimestamp", "Timestamp", "To"])  -data Bitrate = B64 | B128-data Multiplier = M1 | M2-data Order = Popularity | DateAdded-data Status = Yes | Maybe | No+data Bitrate = B64 | B128 deriving Show+data Multiplier = M1 | M2 deriving Show+data Order = Popularity | DateAdded deriving Show+data Status = Yes | Maybe | No deriving Show data Value = ValueUser User            | ValueArtists [Artist]-data Period = Week | Quater | HalfYear | Year | Overall+data Period = Week | Quater | HalfYear | Year | Overall deriving Show   instance Show Value where
src/Network/Lastfm/API/Album.hs view
@@ -6,7 +6,7 @@ import Control.Arrow ((|||)) import Network.Lastfm.Internal -addTags ∷ ResponseType → (Artist, Album) → [Tag] → APIKey → SessionKey → Secret → Lastfm Response+addTags ∷ Format → (Artist, Album) → [Tag] → APIKey → SessionKey → Secret → Lastfm Response addTags t (artist, album) tags apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "album.addTags")   , (#) artist@@ -16,7 +16,7 @@   , (#) sessionKey   ] -getBuyLinks ∷ ResponseType → Either (Artist, Album) Mbid → Maybe Autocorrect → Country → APIKey → Lastfm Response+getBuyLinks ∷ Format → Either (Artist, Album) Mbid → Maybe Autocorrect → Country → APIKey → Lastfm Response getBuyLinks t a autocorrect country apiKey = callAPI t $   target a ++   [ (#) (Method "album.getBuyLinks")@@ -25,7 +25,7 @@   , (#) apiKey   ] -getInfo ∷ ResponseType → Either (Artist, Album) Mbid → Maybe Autocorrect → Maybe Language → Maybe Username → APIKey → Lastfm Response+getInfo ∷ Format → Either (Artist, Album) Mbid → Maybe Autocorrect → Maybe Language → Maybe Username → APIKey → Lastfm Response getInfo t a autocorrect lang username apiKey = callAPI t $   target a ++   [ (#) (Method "album.getInfo")@@ -35,7 +35,7 @@   , (#) apiKey   ] -getShouts ∷ ResponseType → Either (Artist, Album) Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getShouts ∷ Format → Either (Artist, Album) Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getShouts t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "album.getShouts")@@ -45,7 +45,7 @@   , (#) apiKey   ] -getTags ∷ ResponseType → Either (Artist, Album) Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response+getTags ∷ Format → Either (Artist, Album) Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response getTags t a autocorrect b apiKey = case b of   Left user → callAPI t $ target a ++ [(#) user] ++ args   Right (sessionKey, secret) → callAPIsigned t secret $ target a ++ [(#) sessionKey] ++ args@@ -55,7 +55,7 @@           , (#) apiKey           ] -getTopTags ∷ ResponseType → Either (Artist, Album) Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getTopTags ∷ Format → Either (Artist, Album) Mbid → Maybe Autocorrect → APIKey → Lastfm Response getTopTags t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "album.getTopTags")@@ -63,7 +63,7 @@   , (#) apiKey   ] -removeTag ∷ ResponseType → Artist → Album → Tag → APIKey → SessionKey → Secret → Lastfm Response+removeTag ∷ Format → Artist → Album → Tag → APIKey → SessionKey → Secret → Lastfm Response removeTag t artist album tag apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "album.removeTag")   , (#) artist@@ -73,7 +73,7 @@   , (#) sessionKey   ] -search ∷ ResponseType → Album → Maybe Page → Maybe Limit → APIKey → Lastfm Response+search ∷ Format → Album → Maybe Page → Maybe Limit → APIKey → Lastfm Response search t album page limit apiKey = callAPI t   [ (#) (Method "album.search")   , (#) album@@ -82,7 +82,7 @@   , (#) apiKey   ] -share ∷ ResponseType → Artist → Album → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response+share ∷ Format → Artist → Album → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response share t artist album recipient message public apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "album.share")   , (#) artist
src/Network/Lastfm/API/Artist.hs view
@@ -7,7 +7,7 @@ import Control.Arrow ((|||)) import Network.Lastfm.Internal -addTags ∷ ResponseType → Artist → [Tag] → APIKey → SessionKey → Secret → Lastfm Response+addTags ∷ Format → Artist → [Tag] → APIKey → SessionKey → Secret → Lastfm Response addTags t artist tags apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "artist.addTags")   , (#) artist@@ -16,14 +16,14 @@   , (#) sessionKey   ] -getCorrection ∷ ResponseType → Artist → APIKey → Lastfm Response+getCorrection ∷ Format → Artist → APIKey → Lastfm Response getCorrection t artist apiKey = callAPI t   [ (#) (Method "artist.getCorrection")   , (#) artist   , (#) apiKey   ] -getEvents ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → Maybe FestivalsOnly → APIKey → Lastfm Response+getEvents ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → Maybe FestivalsOnly → APIKey → Lastfm Response getEvents t a autocorrect page limit festivalsOnly apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getEvents")@@ -34,7 +34,7 @@   , (#) apiKey   ] -getImages ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → Maybe Order → APIKey → Lastfm Response+getImages ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → Maybe Order → APIKey → Lastfm Response getImages t a autocorrect page limit order apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getImages")@@ -45,7 +45,7 @@   , (#) apiKey   ] -getInfo ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Language → Maybe Username → APIKey → Lastfm Response+getInfo ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Language → Maybe Username → APIKey → Lastfm Response getInfo t a autocorrect language username apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getInfo")@@ -55,7 +55,7 @@   , (#) apiKey   ] -getPastEvents ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getPastEvents ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getPastEvents t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getPastEvents")@@ -65,7 +65,7 @@   , (#) apiKey   ] -getPodcast ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getPodcast ∷ Format → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response getPodcast t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getPodcast")@@ -73,7 +73,7 @@   , (#) apiKey   ] -getShouts ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getShouts ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getShouts t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getShouts")@@ -83,7 +83,7 @@   , (#) apiKey   ] -getSimilar ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Limit → APIKey → Lastfm Response+getSimilar ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Limit → APIKey → Lastfm Response getSimilar t a autocorrect limit apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getSimilar")@@ -92,7 +92,7 @@   , (#) apiKey   ] -getTags ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response+getTags ∷ Format → Either Artist Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response getTags t a autocorrect b apiKey = case b of   Left user → callAPI t $ target a ++ [(#) user] ++ args   Right (sessionKey, secret) → callAPIsigned t secret $ target a ++ [(#) sessionKey] ++ args@@ -102,7 +102,7 @@           , (#) apiKey           ] -getTopAlbums ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopAlbums ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopAlbums t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getTopAlbums")@@ -112,7 +112,7 @@   , (#) apiKey   ] -getTopFans ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getTopFans ∷ Format → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response getTopFans t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getTopFans")@@ -120,7 +120,7 @@   , (#) apiKey   ] -getTopTags ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getTopTags ∷ Format → Either Artist Mbid → Maybe Autocorrect → APIKey → Lastfm Response getTopTags t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getTopTags")@@ -128,7 +128,7 @@   , (#) apiKey   ] -getTopTracks ∷ ResponseType → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTracks ∷ Format → Either Artist Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTracks t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "artist.getTopTracks")@@ -138,7 +138,7 @@   , (#) apiKey   ] -removeTag ∷ ResponseType → Artist → Tag → APIKey → SessionKey → Secret → Lastfm Response+removeTag ∷ Format → Artist → Tag → APIKey → SessionKey → Secret → Lastfm Response removeTag t artist tag apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "artist.removeTag")   , (#) artist@@ -147,7 +147,7 @@   , (#) sessionKey   ] -search ∷ ResponseType → Artist → Maybe Page → Maybe Limit → APIKey → Lastfm Response+search ∷ Format → Artist → Maybe Page → Maybe Limit → APIKey → Lastfm Response search t artist page limit apiKey = callAPI t   [ (#) (Method "artist.search")   , (#) artist@@ -156,7 +156,7 @@   , (#) limit   ] -share ∷ ResponseType → Artist → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response+share ∷ Format → Artist → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response share t artist recipient message public apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "artist.share")   , (#) artist@@ -167,7 +167,7 @@   , (#) message   ] -shout ∷ ResponseType → Artist → Message → APIKey → SessionKey → Secret → Lastfm Response+shout ∷ Format → Artist → Message → APIKey → SessionKey → Secret → Lastfm Response shout t artist message apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "artist.shout")   , (#) artist
src/Network/Lastfm/API/Auth.hs view
@@ -4,16 +4,22 @@   ) where  import Data.Functor ((<$>))+ import Network.Lastfm.Internal+import Network.Lastfm.JSON (json) + getMobileSession ∷ Username → APIKey → AuthToken → Lastfm SessionKey-getMobileSession username apiKey token = simple <$> callAPI JSON [(#) (Method "auth.getMobileSession"), (#) username, (#) token, (#) apiKey]+getMobileSession username apiKey token = simple <$> callAPI json [(#) (Method "auth.getMobileSession"), (#) username, (#) token, (#) apiKey] + getSession ∷ APIKey → Token → Secret → Lastfm SessionKey-getSession apiKey token secret = simple <$> callAPIsigned JSON secret [(#) (Method "auth.getSession"), (#) apiKey, (#) token]+getSession apiKey token secret = simple <$> callAPIsigned json secret [(#) (Method "auth.getSession"), (#) apiKey, (#) token] + getToken ∷ APIKey → Lastfm Token-getToken apiKey = simple <$> callAPI JSON [(#) (Method "auth.getToken"), (#) apiKey]+getToken apiKey = simple <$> callAPI json [(#) (Method "auth.getToken"), (#) apiKey]+  getAuthorizeTokenLink ∷ APIKey → Token → String getAuthorizeTokenLink apiKey token = "http://www.last.fm/api/auth/?api_key=" ++ value apiKey ++ "&token=" ++ value token
src/Network/Lastfm/API/Chart.hs view
@@ -5,25 +5,25 @@  import Network.Lastfm.Internal -getHypedArtists ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getHypedArtists ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getHypedArtists = get "getHypedArtists" -getHypedTracks ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getHypedTracks ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getHypedTracks = get "getHypedTracks" -getLovedTracks ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getLovedTracks ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getLovedTracks = get "getLovedTracks" -getTopArtists ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopArtists ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopArtists = get "getTopArtists" -getTopTags ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTags ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTags = get "getTopTags" -getTopTracks ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTracks ∷ Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTracks = get "getTopTracks" -get ∷ String → ResponseType → Maybe Page → Maybe Limit → APIKey → Lastfm Response+get ∷ String → Format → Maybe Page → Maybe Limit → APIKey → Lastfm Response get method t page limit apiKey = callAPI t   [ (#) (Method $ "chart." ++ method)   , (#) page
src/Network/Lastfm/API/Event.hs view
@@ -4,7 +4,7 @@  import Network.Lastfm.Internal -attend ∷ ResponseType → Event → Status → APIKey → SessionKey → Secret → Lastfm Response+attend ∷ Format → Event → Status → APIKey → SessionKey → Secret → Lastfm Response attend t event status apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "event.attend")   , (#) event@@ -13,7 +13,7 @@   , (#) sessionKey   ] -getAttendees ∷ ResponseType → Event → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getAttendees ∷ Format → Event → Maybe Page → Maybe Limit → APIKey → Lastfm Response getAttendees t event page limit apiKey = callAPI t   [ (#) (Method "event.getAttendees")   , (#) event@@ -22,14 +22,14 @@   , (#) apiKey   ] -getInfo ∷ ResponseType → Event → APIKey → Lastfm Response+getInfo ∷ Format → Event → APIKey → Lastfm Response getInfo t event apiKey = callAPI t   [ (#) (Method "event.getInfo")   , (#) event   , (#) apiKey   ] -getShouts ∷ ResponseType → Event → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getShouts ∷ Format → Event → Maybe Page → Maybe Limit → APIKey → Lastfm Response getShouts t event page limit apiKey = callAPI t   [ (#) (Method "event.getShouts")   , (#) event@@ -38,7 +38,7 @@   , (#) apiKey   ] -share ∷ ResponseType → Event → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response+share ∷ Format → Event → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response share t event recipient message public apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "event.share")   , (#) event@@ -49,7 +49,7 @@   , (#) sessionKey   ] -shout ∷ ResponseType → Event → Message → APIKey → SessionKey → Secret → Lastfm Response+shout ∷ Format → Event → Message → APIKey → SessionKey → Secret → Lastfm Response shout t event message apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "event.shout")   , (#) event
src/Network/Lastfm/API/Geo.hs view
@@ -6,7 +6,7 @@  import Network.Lastfm.Internal -getEvents ∷ ResponseType+getEvents ∷ Format           → Maybe Latitude           → Maybe Longitude           → Maybe Location@@ -26,39 +26,39 @@   , (#) apiKey   ] -getMetroArtistChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroArtistChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroArtistChart = getMetroChart "geo.getMetroArtistChart" -getMetroHypeArtistChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroHypeArtistChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroHypeArtistChart = getMetroChart "geo.getMetroHypeArtistChart" -getMetroHypeTrackChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroHypeTrackChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroHypeTrackChart = getMetroChart "geo.getMetroHypeTrackChart" -getMetroTrackChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroTrackChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroTrackChart = getMetroChart "geo.getMetroTrackChart" -getMetroUniqueArtistChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroUniqueArtistChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroUniqueArtistChart = getMetroChart "geo.getMetroUniqueArtistChart" -getMetroUniqueTrackChart ∷ ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroUniqueTrackChart ∷ Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroUniqueTrackChart = getMetroChart "geo.getMetroUniqueTrackChart" -getMetroWeeklyChartlist ∷ ResponseType → Metro → APIKey → Lastfm Response+getMetroWeeklyChartlist ∷ Format → Metro → APIKey → Lastfm Response getMetroWeeklyChartlist t metro apiKey = callAPI t   [ (#) (Method "geo.getMetroWeeklyChartlist")   , (#) metro   , (#) apiKey   ] -getMetros ∷ ResponseType → Maybe Country → APIKey → Lastfm Response+getMetros ∷ Format → Maybe Country → APIKey → Lastfm Response getMetros t country apiKey = callAPI t   [ (#) (Method "geo.getMetros")   , (#) country   , (#) apiKey   ] -getTopArtists ∷ ResponseType → Country → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopArtists ∷ Format → Country → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopArtists t country page limit apiKey = callAPI t   [ (#) (Method "geo.getTopArtists")   , (#) country@@ -67,7 +67,7 @@   , (#) apiKey   ] -getTopTracks ∷ ResponseType → Country → Maybe Location → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTracks ∷ Format → Country → Maybe Location → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTracks t country location page limit apiKey = callAPI t   [ (#) (Method "geo.getTopTracks")   , (#) country@@ -77,7 +77,7 @@   , (#) apiKey   ] -getMetroChart ∷ String → ResponseType → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response+getMetroChart ∷ String → Format → Country → Metro → Maybe Start → Maybe End → APIKey → Lastfm Response getMetroChart method t country metro start end apiKey = callAPI t   [ (#) (Method method)   , (#) country
src/Network/Lastfm/API/Group.hs view
@@ -4,14 +4,14 @@  import Network.Lastfm.Internal -getHype ∷ ResponseType → Group → APIKey → Lastfm Response+getHype ∷ Format → Group → APIKey → Lastfm Response getHype t group apiKey = callAPI t   [ (#) (Method "group.getHype")   , (#) group   , (#) apiKey   ] -getMembers ∷ ResponseType → Group → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getMembers ∷ Format → Group → Maybe Page → Maybe Limit → APIKey → Lastfm Response getMembers t group page limit apiKey = callAPI t   [ (#) (Method "group.getMembers")   , (#) group@@ -20,14 +20,14 @@   , (#) apiKey   ] -getWeeklyChartList ∷ ResponseType → Group → APIKey → Lastfm Response+getWeeklyChartList ∷ Format → Group → APIKey → Lastfm Response getWeeklyChartList t group apiKey = callAPI t   [ (#) (Method "group.getWeeklyChartList")   , (#) group   , (#) apiKey   ] -getWeeklyAlbumChart ∷ ResponseType → Group → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyAlbumChart ∷ Format → Group → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyAlbumChart t group from to apiKey = callAPI t   [ (#) (Method "group.getWeeklyAlbumChart")   , (#) group@@ -36,7 +36,7 @@   , (#) apiKey   ] -getWeeklyArtistChart ∷ ResponseType → Group → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyArtistChart ∷ Format → Group → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyArtistChart t group from to apiKey = callAPI t   [ (#) (Method "group.getWeeklyArtistChart")   , (#) group@@ -46,7 +46,7 @@   ]  -getWeeklyTrackChart ∷ ResponseType → Group → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyTrackChart ∷ Format → Group → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyTrackChart t group from to apiKey = callAPI t   [ (#) (Method "group.getWeeklyTrackChart")   , (#) group
src/Network/Lastfm/API/Library.hs view
@@ -5,7 +5,7 @@  import Network.Lastfm.Internal -addAlbum ∷ ResponseType → Artist → Album → APIKey → SessionKey → Secret → Lastfm Response+addAlbum ∷ Format → Artist → Album → APIKey → SessionKey → Secret → Lastfm Response addAlbum t artist album apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.addAlbum")   , (#) artist@@ -14,7 +14,7 @@   , (#) sessionKey   ] -addArtist ∷ ResponseType → Artist → APIKey → SessionKey → Secret → Lastfm Response+addArtist ∷ Format → Artist → APIKey → SessionKey → Secret → Lastfm Response addArtist t artist apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.addArtist")   , (#) artist@@ -22,7 +22,7 @@   , (#) sessionKey   ] -addTrack ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+addTrack ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response addTrack t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.addTrack")   , (#) artist@@ -31,7 +31,7 @@   , (#) sessionKey   ] -getAlbums ∷ ResponseType → User → Maybe Artist → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getAlbums ∷ Format → User → Maybe Artist → Maybe Page → Maybe Limit → APIKey → Lastfm Response getAlbums t user artist page limit apiKey = callAPI t   [ (#) (Method "library.getAlbums")   , (#) user@@ -41,7 +41,7 @@   , (#) apiKey   ] -getArtists ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getArtists ∷ Format → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response getArtists t user page limit apiKey = callAPI t   [ (#) (Method "library.getArtists")   , (#) user@@ -50,7 +50,7 @@   , (#) apiKey   ] -getTracks ∷ ResponseType → User → Maybe Artist → Maybe Album → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTracks ∷ Format → User → Maybe Artist → Maybe Album → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTracks t user artist album page limit apiKey = callAPI t   [ (#) (Method "library.getTracks")   , (#) user@@ -61,7 +61,7 @@   , (#) apiKey   ] -removeAlbum ∷ ResponseType → Artist → Album → APIKey → SessionKey → Secret → Lastfm Response+removeAlbum ∷ Format → Artist → Album → APIKey → SessionKey → Secret → Lastfm Response removeAlbum t artist album apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.removeAlbum")   , (#) artist@@ -70,7 +70,7 @@   , (#) sessionKey   ] -removeArtist ∷ ResponseType → Artist → APIKey → SessionKey → Secret → Lastfm Response+removeArtist ∷ Format → Artist → APIKey → SessionKey → Secret → Lastfm Response removeArtist t artist apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.removeArtist")   , (#) artist@@ -78,7 +78,7 @@   , (#) sessionKey   ] -removeScrobble ∷ ResponseType → Artist → Track → Timestamp → APIKey → SessionKey → Secret → Lastfm Response+removeScrobble ∷ Format → Artist → Track → Timestamp → APIKey → SessionKey → Secret → Lastfm Response removeScrobble t artist track timestamp apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.removeScrobble")   , (#) artist@@ -88,7 +88,7 @@   , (#) sessionKey   ] -removeTrack ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+removeTrack ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response removeTrack t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "library.removeTrack")   , (#) artist
src/Network/Lastfm/API/Playlist.hs view
@@ -4,7 +4,7 @@  import Network.Lastfm.Internal -addTrack ∷ ResponseType → Playlist → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+addTrack ∷ Format → Playlist → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response addTrack t playlist artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "playlist.addTrack")   , (#) playlist@@ -14,7 +14,7 @@   , (#) sessionKey   ] -create ∷ ResponseType → Maybe Title → Maybe Description → APIKey → SessionKey → Secret → Lastfm Response+create ∷ Format → Maybe Title → Maybe Description → APIKey → SessionKey → Secret → Lastfm Response create t title description apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "playlist.create")   , (#) title
src/Network/Lastfm/API/Radio.hs view
@@ -4,7 +4,7 @@  import Network.Lastfm.Internal -getPlaylist ∷ ResponseType+getPlaylist ∷ Format             → Maybe Discovery             → Maybe RTP             → Maybe BuyLinks@@ -25,14 +25,14 @@   , (#) sessionKey   ] -search ∷ ResponseType → Name → APIKey → Lastfm Response+search ∷ Format → Name → APIKey → Lastfm Response search t name apiKey = callAPI t   [ (#) (Method "radio.search")   , (#) name   , (#) apiKey   ] -tune ∷ ResponseType → Maybe Language → Station → APIKey → SessionKey → Secret → Lastfm Response+tune ∷ Format → Maybe Language → Station → APIKey → SessionKey → Secret → Lastfm Response tune t language station apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "radio.tune")   , (#) language
src/Network/Lastfm/API/Tag.hs view
@@ -5,7 +5,7 @@  import Network.Lastfm.Internal -getInfo ∷ ResponseType → Tag → Maybe Language → APIKey → Lastfm Response+getInfo ∷ Format → Tag → Maybe Language → APIKey → Lastfm Response getInfo t tag language apiKey = callAPI t   [ (#) (Method "tag.getInfo")   , (#) tag@@ -13,14 +13,14 @@   , (#) apiKey   ] -getSimilar ∷ ResponseType → Tag → APIKey → Lastfm Response+getSimilar ∷ Format → Tag → APIKey → Lastfm Response getSimilar t tag apiKey = callAPI t   [ (#) (Method "tag.getSimilar")   , (#) tag   , (#) apiKey   ] -getTopAlbums ∷ ResponseType → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopAlbums ∷ Format → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopAlbums t tag page limit apiKey = callAPI t   [ (#) (Method "tag.getTopAlbums")   , (#) tag@@ -29,7 +29,7 @@   , (#) apiKey   ] -getTopArtists ∷ ResponseType → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopArtists ∷ Format → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopArtists t tag limit page apiKey = callAPI t   [ (#) (Method "tag.getTopArtists")   , (#) tag@@ -38,13 +38,13 @@   , (#) apiKey   ] -getTopTags ∷ ResponseType → APIKey → Lastfm Response+getTopTags ∷ Format → APIKey → Lastfm Response getTopTags t apiKey = callAPI t-  [ (#) (Method "tag.getTopArtists")+  [ (#) (Method "tag.getTopTags")   , (#) apiKey   ] -getTopTracks ∷ ResponseType → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTracks ∷ Format → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTracks t tag limit page apiKey = callAPI t   [ (#) (Method "tag.getTopTracks")   , (#) tag@@ -53,7 +53,7 @@   , (#) apiKey   ] -getWeeklyArtistChart ∷ ResponseType → Tag → Maybe From → Maybe To → Maybe Limit → APIKey → Lastfm Response+getWeeklyArtistChart ∷ Format → Tag → Maybe From → Maybe To → Maybe Limit → APIKey → Lastfm Response getWeeklyArtistChart t tag from to limit apiKey = callAPI t   [ (#) (Method "tag.getWeeklyArtistChart")   , (#) tag@@ -63,14 +63,14 @@   , (#) apiKey   ] -getWeeklyChartList ∷ ResponseType → Tag → APIKey → Lastfm Response+getWeeklyChartList ∷ Format → Tag → APIKey → Lastfm Response getWeeklyChartList t tag apiKey = callAPI t   [ (#) (Method "tag.getWeeklyChartList")   , (#) tag   , (#) apiKey   ] -search ∷ ResponseType → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response+search ∷ Format → Tag → Maybe Page → Maybe Limit → APIKey → Lastfm Response search t tag page limit apiKey = callAPI t   [ (#) (Method "tag.search")   , (#) tag
src/Network/Lastfm/API/Tasteometer.hs view
@@ -8,7 +8,7 @@ (?<) ∷ Argument a ⇒ a → Int → (String, String) a ?< n = (key a ++ show n, value a) -compare ∷ ResponseType → Value → Value → Maybe Limit → APIKey → Lastfm Response+compare ∷ Format → Value → Value → Maybe Limit → APIKey → Lastfm Response compare t value1 value2 limit apiKey = callAPI t   [ (#) (Method "tasteometer.compare")   , (,) "type1" (show value1)
src/Network/Lastfm/API/Track.hs view
@@ -7,7 +7,7 @@ import Control.Arrow ((|||)) import Network.Lastfm.Internal -addTags ∷ ResponseType → Artist → Track → [Tag] → APIKey → SessionKey → Secret → Lastfm Response+addTags ∷ Format → Artist → Track → [Tag] → APIKey → SessionKey → Secret → Lastfm Response addTags t artist track tags apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.addTags")   , (#) artist@@ -17,7 +17,7 @@   , (#) sessionKey   ] -ban ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+ban ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response ban t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.ban")   , (#) artist@@ -26,7 +26,7 @@   , (#) sessionKey   ] -getBuyLinks ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → Country → APIKey → Lastfm Response+getBuyLinks ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → Country → APIKey → Lastfm Response getBuyLinks t a autocorrect country apiKey = callAPI t $   target a ++   [ (#) (Method "track.getBuyLinks")@@ -35,7 +35,7 @@   , (#) apiKey   ] -getCorrection ∷ ResponseType → Artist → Track → APIKey → Lastfm Response+getCorrection ∷ Format → Artist → Track → APIKey → Lastfm Response getCorrection t artist track apiKey = callAPI t   [ (#) (Method "track.getCorrection")   , (#) artist@@ -43,14 +43,14 @@   , (#) apiKey   ] -getFingerprintMetadata ∷ ResponseType → Fingerprint → APIKey → Lastfm Response+getFingerprintMetadata ∷ Format → Fingerprint → APIKey → Lastfm Response getFingerprintMetadata t fingerprint apiKey = callAPI t   [ (#) (Method "track.getFingerprintMetadata")   , (#) fingerprint   , (#) apiKey   ] -getInfo ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Username → APIKey → Lastfm Response+getInfo ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Username → APIKey → Lastfm Response getInfo t a autocorrect username apiKey = callAPI t $   target a ++   [ (#) (Method "track.getInfo")@@ -59,7 +59,7 @@   , (#) apiKey   ] -getShouts ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getShouts ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Page → Maybe Limit → APIKey → Lastfm Response getShouts t a autocorrect page limit apiKey = callAPI t $   target a ++   [ (#) (Method "track.getShouts")@@ -69,7 +69,7 @@   , (#) apiKey   ] -getSimilar ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Limit → APIKey → Lastfm Response+getSimilar ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → Maybe Limit → APIKey → Lastfm Response getSimilar t a autocorrect limit apiKey = callAPI t $   target a ++   [ (#) (Method "track.getSimilar")@@ -78,7 +78,7 @@   , (#) apiKey   ] -getTags ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response+getTags ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → Either User (SessionKey, Secret) → APIKey → Lastfm Response getTags t a autocorrect b apiKey = case b of   Left user → callAPI t $ target a ++ [(#) user] ++ args   Right (sessionKey, secret) → callAPIsigned t secret $ target a ++ [(#) sessionKey] ++ args@@ -88,7 +88,7 @@           , (#) apiKey           ] -getTopFans ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getTopFans ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → APIKey → Lastfm Response getTopFans t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "track.getTopFans")@@ -96,7 +96,7 @@   , (#) apiKey   ] -getTopTags ∷ ResponseType → Either (Artist, Track) Mbid → Maybe Autocorrect → APIKey → Lastfm Response+getTopTags ∷ Format → Either (Artist, Track) Mbid → Maybe Autocorrect → APIKey → Lastfm Response getTopTags t a autocorrect apiKey = callAPI t $   target a ++   [ (#) (Method "track.getTopTags")@@ -104,7 +104,7 @@   , (#) apiKey   ] -love ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+love ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response love t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.love")   , (#) artist@@ -113,7 +113,7 @@   , (#) sessionKey   ] -removeTag ∷ ResponseType → Artist → Track → Tag → APIKey → SessionKey → Secret → Lastfm Response+removeTag ∷ Format → Artist → Track → Tag → APIKey → SessionKey → Secret → Lastfm Response removeTag t artist track tag apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.removeTag")   , (#) artist@@ -123,7 +123,7 @@   , (#) sessionKey   ] -scrobble ∷ ResponseType → ( Timestamp, Maybe Album, Artist, Track, Maybe AlbumArtist+scrobble ∷ Format → ( Timestamp, Maybe Album, Artist, Track, Maybe AlbumArtist            , Maybe Duration, Maybe StreamId, Maybe ChosenByUser            , Maybe Context, Maybe TrackNumber, Maybe Mbid )          → APIKey@@ -147,7 +147,7 @@   , (#) sessionKey   ] -search ∷ ResponseType → Track → Maybe Page → Maybe Limit → Maybe Artist → APIKey → Lastfm Response+search ∷ Format → Track → Maybe Page → Maybe Limit → Maybe Artist → APIKey → Lastfm Response search t track page limit artist apiKey = callAPI t   [ (#) (Method "track.search")   , (#) track@@ -157,7 +157,7 @@   , (#) apiKey   ] -share ∷ ResponseType → Artist → Track → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response+share ∷ Format → Artist → Track → Recipient → Maybe Message → Maybe Public → APIKey → SessionKey → Secret → Lastfm Response share t artist track recipient message public apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.share")   , (#) artist@@ -169,7 +169,7 @@   , (#) sessionKey   ] -unban ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+unban ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response unban t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.unban")   , (#) artist@@ -178,7 +178,7 @@   , (#) sessionKey   ] -unlove ∷ ResponseType → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response+unlove ∷ Format → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response unlove t artist track apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "track.unlove")   , (#) artist@@ -188,7 +188,7 @@   ]  -updateNowPlaying ∷ ResponseType → Artist+updateNowPlaying ∷ Format → Artist                  → Track                  → Maybe Album                  → Maybe AlbumArtist
src/Network/Lastfm/API/User.hs view
@@ -8,7 +8,7 @@  import Network.Lastfm.Internal -getArtistTracks ∷ ResponseType → User → Artist → Maybe StartTimestamp → Maybe EndTimestamp → Maybe Page → APIKey → Lastfm Response+getArtistTracks ∷ Format → User → Artist → Maybe StartTimestamp → Maybe EndTimestamp → Maybe Page → APIKey → Lastfm Response getArtistTracks t user artist startTimestamp endTimestamp page apiKey = callAPI t   [ (#) (Method "user.getArtistTracks")   , (#) user@@ -19,7 +19,7 @@   , (#) apiKey   ] -getBannedTracks ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getBannedTracks ∷ Format → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response getBannedTracks t user page limit apiKey = callAPI t   [ (#) (Method "user.getBannedTracks")   , (#) user@@ -28,7 +28,7 @@   , (#) apiKey   ] -getEvents ∷ ResponseType → User → Maybe Page → Maybe Limit → Maybe FestivalsOnly → APIKey → Lastfm Response+getEvents ∷ Format → User → Maybe Page → Maybe Limit → Maybe FestivalsOnly → APIKey → Lastfm Response getEvents t user page limit festivalsOnly apiKey = callAPI t   [ (#) (Method "user.getEvents")   , (#) user@@ -38,7 +38,7 @@   , (#) apiKey   ] -getFriends ∷ ResponseType → User → Maybe RecentTracks → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getFriends ∷ Format → User → Maybe RecentTracks → Maybe Page → Maybe Limit → APIKey → Lastfm Response getFriends t user recentTracks page limit apiKey = callAPI t   [ (#) (Method "user.getFriends")   , (#) user@@ -48,14 +48,14 @@   , (#) apiKey   ] -getInfo ∷ ResponseType → Maybe User → APIKey → Lastfm Response+getInfo ∷ Format → Maybe User → APIKey → Lastfm Response getInfo t user apiKey = callAPI t   [ (#) (Method "user.getInfo")   , (#) user   , (#) apiKey   ] -getLovedTracks ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getLovedTracks ∷ Format → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response getLovedTracks t user page limit apiKey = callAPI t   [ (#) (Method "user.getLovedTracks")   , (#) user@@ -64,7 +64,7 @@   , (#) apiKey   ] -getNeighbours ∷ ResponseType → User → Maybe Limit → APIKey → Lastfm Response+getNeighbours ∷ Format → User → Maybe Limit → APIKey → Lastfm Response getNeighbours t user limit apiKey = callAPI t   [ (#) (Method "user.getNeighbours")   , (#) user@@ -72,7 +72,7 @@   , (#) apiKey   ] -getNewReleases ∷ ResponseType → User → Maybe UseRecs → APIKey → Lastfm Response+getNewReleases ∷ Format → User → Maybe UseRecs → APIKey → Lastfm Response getNewReleases t user useRecs apiKey = callAPI t   [ (#) (Method "user.getNewReleases")   , (#) user@@ -80,7 +80,7 @@   , (#) apiKey   ] -getPastEvents ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getPastEvents ∷ Format → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response getPastEvents t user page limit apiKey = callAPI t   [ (#) (Method "user.getPastEvents")   , (#) user@@ -89,7 +89,7 @@   , (#) apiKey   ] -getPersonalTags ∷ ResponseType+getPersonalTags ∷ Format                 → User                 → Tag                 → TaggingType@@ -107,14 +107,14 @@   , (#) apiKey   ] -getPlaylists ∷ ResponseType → User → APIKey → Lastfm Response+getPlaylists ∷ Format → User → APIKey → Lastfm Response getPlaylists t user apiKey = callAPI t   [ (#) (Method "user.getPlaylists")   , (#) user   , (#) apiKey   ] -getRecentStations ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response+getRecentStations ∷ Format → User → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response getRecentStations t user page limit apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "user.getRecentStations")   , (#) user@@ -124,7 +124,7 @@   , (#) sessionKey   ] -getRecentTracks ∷ ResponseType → User → Maybe Page → Maybe Limit → Maybe From → Maybe To → APIKey → Lastfm Response+getRecentTracks ∷ Format → User → Maybe Page → Maybe Limit → Maybe From → Maybe To → APIKey → Lastfm Response getRecentTracks t user page limit from to apiKey = callAPI t   [ (#) (Method "user.getRecentTracks")   , (#) user@@ -135,7 +135,7 @@   , (#) apiKey   ] -getRecommendedArtists ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response+getRecommendedArtists ∷ Format → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response getRecommendedArtists t page limit apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "user.getRecommendedArtists")   , (#) page@@ -144,7 +144,7 @@   , (#) sessionKey   ] -getRecommendedEvents ∷ ResponseType → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response+getRecommendedEvents ∷ Format → Maybe Page → Maybe Limit → APIKey → SessionKey → Secret → Lastfm Response getRecommendedEvents t page limit apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "user.getRecommendedEvents")   , (#) page@@ -153,7 +153,7 @@   , (#) sessionKey   ] -getShouts ∷ ResponseType → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getShouts ∷ Format → User → Maybe Page → Maybe Limit → APIKey → Lastfm Response getShouts t user page limit apiKey = callAPI t   [ (#) (Method "user.getShouts")   , (#) user@@ -162,7 +162,7 @@   , (#) apiKey   ] -getTopAlbums ∷ ResponseType → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopAlbums ∷ Format → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopAlbums t user period page limit apiKey = callAPI t   [ (#) (Method "user.getTopAlbums")   , (#) user@@ -172,7 +172,7 @@   , (#) apiKey   ] -getTopArtists ∷ ResponseType → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopArtists ∷ Format → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopArtists t user period page limit apiKey = callAPI t   [ (#) (Method "user.getTopArtists")   , (#) user@@ -182,7 +182,7 @@   , (#) apiKey   ] -getTopTags ∷ ResponseType → User → Maybe Limit → APIKey → Lastfm Response+getTopTags ∷ Format → User → Maybe Limit → APIKey → Lastfm Response getTopTags t user limit apiKey = callAPI t   [ (#) (Method "user.getTopTags")   , (#) user@@ -190,7 +190,7 @@   , (#) apiKey   ] -getTopTracks ∷ ResponseType → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getTopTracks ∷ Format → User → Maybe Period → Maybe Page → Maybe Limit → APIKey → Lastfm Response getTopTracks t user period page limit apiKey = callAPI t   [ (#) (Method "user.getTopTracks")   , (#) user@@ -200,7 +200,7 @@   , (#) apiKey   ] -getWeeklyAlbumChart ∷ ResponseType → User → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyAlbumChart ∷ Format → User → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyAlbumChart t user from to apiKey = callAPI t   [ (#) (Method "user.getWeeklyAlbumChart")   , (#) user@@ -209,7 +209,7 @@   , (#) apiKey   ] -getWeeklyArtistChart ∷ ResponseType → User → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyArtistChart ∷ Format → User → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyArtistChart t user from to apiKey = callAPI t   [ (#) (Method "user.getWeeklyArtistChart")   , (#) user@@ -218,14 +218,14 @@   , (#) apiKey   ] -getWeeklyChartList ∷ ResponseType → User → APIKey → Lastfm Response+getWeeklyChartList ∷ Format → User → APIKey → Lastfm Response getWeeklyChartList t user apiKey = callAPI t   [ (#) (Method "user.getWeeklyChartList")   , (#) user   , (#) apiKey   ] -getWeeklyTrackChart ∷ ResponseType → User → Maybe From → Maybe To → APIKey → Lastfm Response+getWeeklyTrackChart ∷ Format → User → Maybe From → Maybe To → APIKey → Lastfm Response getWeeklyTrackChart t user from to apiKey = callAPI t   [ (#) (Method "user.getWeeklyTrackChart")   , (#) user@@ -234,7 +234,7 @@   , (#) apiKey   ] -shout ∷ ResponseType → User → Message → APIKey → SessionKey → Secret → Lastfm Response+shout ∷ Format → User → Message → APIKey → SessionKey → Secret → Lastfm Response shout t user message apiKey sessionKey secret = callAPIsigned t secret   [ (#) (Method "user.shout")   , (#) user
src/Network/Lastfm/API/Venue.hs view
@@ -4,7 +4,7 @@  import Network.Lastfm.Internal -getEvents ∷ ResponseType → Venue → Maybe FestivalsOnly → APIKey → Lastfm Response+getEvents ∷ Format → Venue → Maybe FestivalsOnly → APIKey → Lastfm Response getEvents t venue festivalsOnly apiKey = callAPI t   [ (#) (Method "venue.getEvents")   , (#) venue@@ -12,7 +12,7 @@   , (#) apiKey   ] -getPastEvents ∷ ResponseType → Venue → Maybe FestivalsOnly → Maybe Page → Maybe Limit → APIKey → Lastfm Response+getPastEvents ∷ Format → Venue → Maybe FestivalsOnly → Maybe Page → Maybe Limit → APIKey → Lastfm Response getPastEvents t venue festivalsOnly page limit apiKey = callAPI t   [ (#) (Method "venue.getPastEvents")   , (#) venue@@ -22,7 +22,7 @@   , (#) apiKey   ] -search ∷ ResponseType → Venuename → Maybe Page → Maybe Limit → Maybe Country → APIKey → Lastfm Response+search ∷ Format → Venuename → Maybe Page → Maybe Limit → Maybe Country → APIKey → Lastfm Response search t venue page limit country apiKey = callAPI t   [ (#) (Method "venue.search")   , (#) venue
src/Network/Lastfm/Error.hs view
@@ -1,16 +1,10 @@ {-# LANGUAGE OverloadedStrings #-} module Network.Lastfm.Error   ( LastfmError(..)-  , jsonError, xmlError+  , disambiguate   ) where -import Control.Applicative ((<$>), empty)-import Control.Monad ((<=<))--import Data.Aeson-import Data.ByteString.Lazy.Char8 (ByteString) import Network.Curl (CurlCode)-import Text.XML.Light   data LastfmError@@ -78,19 +72,6 @@     RateLimitExceeded      → ["RateLimitExceeded:",      "Your IP has made too many requests in a short period"]     UnknownError n         → ["UnknownError:",           "Lastfm API specs say nothing about this particular error:", show n]     CurlError s            → ["CurlError:", show s]---instance FromJSON LastfmError where-  parseJSON (Object v) = disambiguate <$> v .: "error"-  parseJSON _ = empty---xmlError ∷ ByteString → Maybe LastfmError-xmlError r = disambiguate . read <$> (findAttr (unqual "code") <=< findChild (unqual "error") <=< parseXMLDoc) r---jsonError ∷ ByteString → Maybe LastfmError-jsonError = decode   disambiguate ∷ Int → LastfmError
src/Network/Lastfm/Internal.hs view
@@ -2,8 +2,8 @@ -- | Response module {-# OPTIONS_HADDOCK hide #-} module Network.Lastfm.Internal-  ( ResponseType(..)-  , callAPI, callAPIsigned, xml, json, (#)+  ( Format(..)+  , callAPI, callAPIsigned, (#)   , module Network.Lastfm   ) where @@ -20,36 +20,26 @@ import Network.Curl  import Network.Lastfm-import Network.Lastfm.Error-import Network.Lastfm.TH  +-- Response format+data Format = Format { errorParser ∷ Response → Maybe LastfmError, uriArgument ∷ (String, String) }++ -- Send POST query to Lastfm API-callAPI ∷ ResponseType → [(String, String)] → Lastfm Response-callAPI t = query (parseError t) . insertType t . map (second encodeString)+callAPI ∷ Format → [(String, String)] → Lastfm Response+callAPI Format {errorParser = e, uriArgument = arg} = query e . (arg:) . map (second encodeString)   -- Send signed POST query to Lastfm API-callAPIsigned ∷ ResponseType → Secret → [(String, String)] → Lastfm Response-callAPIsigned t (Secret s) xs = query (parseError t) zs+callAPIsigned ∷ Format → Secret → [(String, String)] → Lastfm Response+callAPIsigned Format {errorParser = e, uriArgument = arg} (Secret s) xs = query e zs  where   ys = map (second encodeString) . filter (not . null . snd) $ xs-  zs = insertType t $ ("api_sig", sign ys) : ys+  zs = (arg :) $ ("api_sig", sign ys) : ys    sign ∷ [(String, String)] → String   sign = show . md5 . BS.pack . (++ s) . concatMap (uncurry (++)) . sortBy (compare `on` fst)----- Insert desired response type into query-insertType ∷ ResponseType → [(String, String)] → [(String, String)]-insertType XML = id-insertType JSON = (("format", "json") :)----- Try to find error message in Lastfm response-parseError ∷ ResponseType → ByteString → Maybe LastfmError-parseError XML = xmlError-parseError JSON = jsonError   query ∷ (ByteString → Maybe LastfmError) → [(String, String)] → IO (Either LastfmError Response)
+ src/Network/Lastfm/JSON.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+module Network.Lastfm.JSON+  ( json+  , jsonWrapper+  ) where++import Control.Applicative ((<$>), empty)++import Data.Aeson hiding (json)+import Language.Haskell.TH++import Network.Lastfm.Internal (Format(..))+import Network.Lastfm.Error (LastfmError, disambiguate)+++json ∷ Format+json = Format+        { errorParser = decode+        , uriArgument = ("format","json")+        }+++instance FromJSON LastfmError where+  parseJSON (Object v) = disambiguate <$> v .: "error"+  parseJSON _ = empty+++jsonWrapper ∷ [String] → Q [Dec]+jsonWrapper = mapM func+  where+   func xs = funD (mkName xs) [clause [] (normalB $ appE (varE (mkName ("API." ++ xs))) [e| json |]) []]
src/Network/Lastfm/JSON/Album.hs view
@@ -10,9 +10,10 @@ #include "album.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Album as API -$(json ["addTags", "getBuyLinks", "getInfo", "getShouts", "getTags", "getTopTags", "removeTag", "search", "share"])+$(jsonWrapper ["addTags", "getBuyLinks", "getInfo", "getShouts", "getTags", "getTopTags", "removeTag", "search", "share"])  __addTags__ addTags ∷ (Artist, Album) → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/Artist.hs view
@@ -11,9 +11,10 @@ #include "artist.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Artist as API -$(json ["addTags", "getCorrection", "getEvents", "getImages", "getInfo", "getPastEvents", "getPodcast", "getShouts", "getSimilar", "getTags", "getTopAlbums", "getTopFans", "getTopTags", "getTopTracks", "removeTag", "search", "share", "shout"])+$(jsonWrapper ["addTags", "getCorrection", "getEvents", "getImages", "getInfo", "getPastEvents", "getPodcast", "getShouts", "getSimilar", "getTags", "getTopAlbums", "getTopFans", "getTopTags", "getTopTracks", "removeTag", "search", "share", "shout"])  __addTags__ addTags ∷ Artist → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/Chart.hs view
@@ -10,9 +10,10 @@ #include "chart.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Chart as API -$(json ["getHypedArtists", "getHypedTracks", "getLovedTracks", "getTopArtists", "getTopTags", "getTopTracks"])+$(jsonWrapper ["getHypedArtists", "getHypedTracks", "getLovedTracks", "getTopArtists", "getTopTags", "getTopTracks"])  __getHypedArtists__ getHypedArtists ∷ Maybe Page → Maybe Limit → APIKey → Lastfm Response
src/Network/Lastfm/JSON/Event.hs view
@@ -9,9 +9,10 @@ #include "event.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Event as API -$(json ["attend", "getAttendees", "getInfo", "getShouts", "share", "shout"])+$(jsonWrapper ["attend", "getAttendees", "getInfo", "getShouts", "share", "shout"])  __attend__ attend ∷ Event → Status → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/Geo.hs view
@@ -11,9 +11,10 @@ #include "geo.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Geo as API -$(json ["getEvents", "getMetroArtistChart", "getMetroHypeArtistChart", "getMetroHypeTrackChart", "getMetroTrackChart", "getMetroUniqueArtistChart", "getMetroUniqueTrackChart", "getMetroWeeklyChartlist", "getMetros", "getTopArtists", "getTopTracks"])+$(jsonWrapper ["getEvents", "getMetroArtistChart", "getMetroHypeArtistChart", "getMetroHypeTrackChart", "getMetroTrackChart", "getMetroUniqueArtistChart", "getMetroUniqueTrackChart", "getMetroWeeklyChartlist", "getMetros", "getTopArtists", "getTopTracks"])  __getEvents__ getEvents ∷ Maybe Latitude
src/Network/Lastfm/JSON/Group.hs view
@@ -9,9 +9,10 @@ #include "group.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Group as API -$(json ["getHype", "getMembers", "getWeeklyChartList", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyTrackChart"])+$(jsonWrapper ["getHype", "getMembers", "getWeeklyChartList", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyTrackChart"])  __getHype__ getHype ∷ Group → APIKey → Lastfm Response
src/Network/Lastfm/JSON/Library.hs view
@@ -10,9 +10,10 @@ #include "library.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Library as API -$(json ["addAlbum", "addArtist", "addTrack", "getAlbums", "getArtists", "getTracks", "removeAlbum", "removeArtist", "removeScrobble", "removeTrack"])+$(jsonWrapper ["addAlbum", "addArtist", "addTrack", "getAlbums", "getArtists", "getTracks", "removeAlbum", "removeArtist", "removeScrobble", "removeTrack"])  __addAlbum__ addAlbum ∷ Artist → Album → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/Playlist.hs view
@@ -9,9 +9,10 @@ #include "playlist.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Playlist as API -$(json ["addTrack", "create"])+$(jsonWrapper ["addTrack", "create"])  __addTrack__ addTrack ∷ Playlist → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/Radio.hs view
@@ -9,9 +9,10 @@ #include "radio.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Radio as API -$(json ["getPlaylist", "search", "tune"])+$(jsonWrapper ["getPlaylist", "search", "tune"])  __getPlaylist__ getPlaylist ∷ Maybe Discovery
src/Network/Lastfm/JSON/Tag.hs view
@@ -10,9 +10,10 @@ #include "tag.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Tag as API -$(json ["getInfo", "getSimilar", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyArtistChart", "getWeeklyChartList", "search"])+$(jsonWrapper ["getInfo", "getSimilar", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyArtistChart", "getWeeklyChartList", "search"])  __getInfo__ getInfo ∷ Tag → Maybe Language → APIKey → Lastfm Response
src/Network/Lastfm/JSON/Tasteometer.hs view
@@ -11,9 +11,10 @@ import Prelude hiding (compare)  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Tasteometer as API -$(json ["compare"])+$(jsonWrapper ["compare"])  __compare__ compare ∷ Value → Value → Maybe Limit → APIKey → Lastfm Response
src/Network/Lastfm/JSON/Track.hs view
@@ -11,9 +11,10 @@ #include "track.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Track as API -$(json ["addTags", "ban", "getBuyLinks", "getCorrection", "getFingerprintMetadata", "getInfo", "getShouts", "getSimilar", "getTags", "getTopFans", "getTopTags", "love", "removeTag", "scrobble", "search", "share", "unban", "unlove", "updateNowPlaying"])+$(jsonWrapper ["addTags", "ban", "getBuyLinks", "getCorrection", "getFingerprintMetadata", "getInfo", "getShouts", "getSimilar", "getTags", "getTopFans", "getTopTags", "love", "removeTag", "scrobble", "search", "share", "unban", "unlove", "updateNowPlaying"])  __addTags__ addTags ∷ Artist → Track → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/JSON/User.hs view
@@ -13,9 +13,10 @@ #include "user.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.User as API -$(json ["getArtistTracks", "getBannedTracks", "getEvents", "getFriends", "getInfo", "getLovedTracks", "getNeighbours", "getNewReleases", "getPastEvents", "getPersonalTags", "getPlaylists", "getRecentStations", "getRecentTracks", "getRecommendedArtists", "getRecommendedEvents", "getShouts", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyChartList", "getWeeklyTrackChart", "shout"])+$(jsonWrapper ["getArtistTracks", "getBannedTracks", "getEvents", "getFriends", "getInfo", "getLovedTracks", "getNeighbours", "getNewReleases", "getPastEvents", "getPersonalTags", "getPlaylists", "getRecentStations", "getRecentTracks", "getRecommendedArtists", "getRecommendedEvents", "getShouts", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyChartList", "getWeeklyTrackChart", "shout"])  __getArtistTracks__ getArtistTracks ∷ User → Artist → Maybe StartTimestamp → Maybe EndTimestamp → Maybe Page → APIKey → Lastfm Response
src/Network/Lastfm/JSON/Venue.hs view
@@ -9,9 +9,10 @@ #include "venue.docs"  import Network.Lastfm.Internal+import Network.Lastfm.JSON (jsonWrapper) import qualified Network.Lastfm.API.Venue as API -$(json ["getEvents", "getPastEvents", "search"])+$(jsonWrapper ["getEvents", "getPastEvents", "search"])  __getEvents__ getEvents ∷ Venue → Maybe FestivalsOnly → APIKey → Lastfm Response
src/Network/Lastfm/TH.hs view
@@ -1,32 +1,12 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ViewPatterns #-} module Network.Lastfm.TH-  ( ResponseType(..)-  , xml, json-  , instances, newtypes+  ( instances, newtypes   ) where  import Language.Haskell.TH  --- Desired type of Lastfm response-data ResponseType = XML | JSON----- Construct XML wrapper to specified API function-xml ∷ [String] → Q [Dec]-xml = mapM func-  where-   func xs = funD (mkName xs) [clause [] (normalB $ appE (varE (mkName ("API." ++ xs))) [e| XML |]) []]----- Construct JSON wrapper to specified API function-json ∷ [String] → Q [Dec]-json = mapM func-  where-   func xs = funD (mkName xs) [clause [] (normalB $ appE (varE (mkName ("API." ++ xs))) [e| JSON |]) []]-- instances ∷ String → [(String, String)] → Q [Dec] instances f = mapM (instanceDeclaration "Argument")   where@@ -41,4 +21,4 @@ newtypes ∷ String → [String] → Q [Dec] newtypes (mkName → t) (map mkName → ns) = mapM newtypeDeclaration ns   where-   newtypeDeclaration n = newtypeD (cxt []) n [] (normalC n [strictType notStrict (conT t)]) []+   newtypeDeclaration n = newtypeD (cxt []) n [] (normalC n [strictType notStrict (conT t)]) [mkName "Show"]
+ src/Network/Lastfm/XML.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE TemplateHaskell #-}+module Network.Lastfm.XML+  ( xml+  , xmlWrapper+  ) where++import Control.Applicative ((<$>))+import Control.Monad ((<=<))++import Data.ByteString.Lazy.Char8 (ByteString)+import Language.Haskell.TH+import Text.XML.Light++import Network.Lastfm.Error (LastfmError, disambiguate)+import Network.Lastfm.Internal (Format(..))+++xml ∷ Format+xml = Format+        { errorParser = xmlErrorParser+        , uriArgument = ("format","xml")+        }+++xmlWrapper ∷ [String] → Q [Dec]+xmlWrapper = mapM func+  where+   func xs = funD (mkName xs) [clause [] (normalB $ appE (varE (mkName ("API." ++ xs))) [e| xml |]) []]+++xmlErrorParser ∷ ByteString → Maybe LastfmError+xmlErrorParser r = disambiguate . read <$> (findAttr (unqual "code") <=< findChild (unqual "error") <=< parseXMLDoc) r
src/Network/Lastfm/XML/Album.hs view
@@ -10,9 +10,10 @@ #include "album.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Album as API -$(xml ["addTags", "getBuyLinks", "getInfo", "getShouts", "getTags", "getTopTags", "removeTag", "search", "share"])+$(xmlWrapper ["addTags", "getBuyLinks", "getInfo", "getShouts", "getTags", "getTopTags", "removeTag", "search", "share"])  __addTags__ addTags ∷ (Artist, Album) → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/Artist.hs view
@@ -11,9 +11,10 @@ #include "artist.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Artist as API -$(xml ["addTags", "getCorrection", "getEvents", "getImages", "getInfo", "getPastEvents", "getPodcast", "getShouts", "getSimilar", "getTags", "getTopAlbums", "getTopFans", "getTopTags", "getTopTracks", "removeTag", "search", "share", "shout"])+$(xmlWrapper ["addTags", "getCorrection", "getEvents", "getImages", "getInfo", "getPastEvents", "getPodcast", "getShouts", "getSimilar", "getTags", "getTopAlbums", "getTopFans", "getTopTags", "getTopTracks", "removeTag", "search", "share", "shout"])  __addTags__ addTags ∷ Artist → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/Chart.hs view
@@ -10,9 +10,10 @@ #include "chart.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Chart as API -$(xml ["getHypedArtists", "getHypedTracks", "getLovedTracks", "getTopArtists", "getTopTags", "getTopTracks"])+$(xmlWrapper ["getHypedArtists", "getHypedTracks", "getLovedTracks", "getTopArtists", "getTopTags", "getTopTracks"])  __getHypedArtists__ getHypedArtists ∷ Maybe Page → Maybe Limit → APIKey → Lastfm Response
src/Network/Lastfm/XML/Event.hs view
@@ -9,9 +9,10 @@ #include "event.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Event as API -$(xml ["attend", "getAttendees", "getInfo", "getShouts", "share", "shout"])+$(xmlWrapper ["attend", "getAttendees", "getInfo", "getShouts", "share", "shout"])  __attend__ attend ∷ Event → Status → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/Geo.hs view
@@ -11,9 +11,10 @@ #include "geo.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Geo as API -$(xml ["getEvents", "getMetroArtistChart", "getMetroHypeArtistChart", "getMetroHypeTrackChart", "getMetroTrackChart", "getMetroUniqueArtistChart", "getMetroUniqueTrackChart", "getMetroWeeklyChartlist", "getMetros", "getTopArtists", "getTopTracks"])+$(xmlWrapper ["getEvents", "getMetroArtistChart", "getMetroHypeArtistChart", "getMetroHypeTrackChart", "getMetroTrackChart", "getMetroUniqueArtistChart", "getMetroUniqueTrackChart", "getMetroWeeklyChartlist", "getMetros", "getTopArtists", "getTopTracks"])  __getEvents__ getEvents ∷ Maybe Latitude
src/Network/Lastfm/XML/Group.hs view
@@ -9,9 +9,10 @@ #include "group.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Group as API -$(xml ["getHype", "getMembers", "getWeeklyChartList", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyTrackChart"])+$(xmlWrapper ["getHype", "getMembers", "getWeeklyChartList", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyTrackChart"])  __getHype__ getHype ∷ Group → APIKey → Lastfm Response
src/Network/Lastfm/XML/Library.hs view
@@ -10,9 +10,10 @@ #include "library.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Library as API -$(xml ["addAlbum", "addArtist", "addTrack", "getAlbums", "getArtists", "getTracks", "removeAlbum", "removeArtist", "removeScrobble", "removeTrack"])+$(xmlWrapper ["addAlbum", "addArtist", "addTrack", "getAlbums", "getArtists", "getTracks", "removeAlbum", "removeArtist", "removeScrobble", "removeTrack"])  __addAlbum__ addAlbum ∷ Artist → Album → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/Playlist.hs view
@@ -9,9 +9,10 @@ #include "playlist.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Playlist as API -$(xml ["addTrack", "create"])+$(xmlWrapper ["addTrack", "create"])  __addTrack__ addTrack ∷ Playlist → Artist → Track → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/Radio.hs view
@@ -9,9 +9,10 @@ #include "radio.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Radio as API -$(xml ["getPlaylist", "search", "tune"])+$(xmlWrapper ["getPlaylist", "search", "tune"])  __getPlaylist__ getPlaylist ∷ Maybe Discovery
src/Network/Lastfm/XML/Tag.hs view
@@ -10,9 +10,10 @@ #include "tag.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Tag as API -$(xml ["getInfo", "getSimilar", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyArtistChart", "getWeeklyChartList", "search"])+$(xmlWrapper ["getInfo", "getSimilar", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyArtistChart", "getWeeklyChartList", "search"])  __getInfo__ getInfo ∷ Tag → Maybe Language → APIKey → Lastfm Response
src/Network/Lastfm/XML/Tasteometer.hs view
@@ -11,9 +11,10 @@ import Prelude hiding (compare)  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Tasteometer as API -$(xml ["compare"])+$(xmlWrapper ["compare"])  __compare__ compare ∷ Value → Value → Maybe Limit → APIKey → Lastfm Response
src/Network/Lastfm/XML/Track.hs view
@@ -11,9 +11,10 @@ #include "track.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Track as API -$(xml ["addTags", "ban", "getBuyLinks", "getCorrection", "getFingerprintMetadata", "getInfo", "getShouts", "getSimilar", "getTags", "getTopFans", "getTopTags", "love", "removeTag", "scrobble", "search", "share", "unban", "unlove", "updateNowPlaying"])+$(xmlWrapper ["addTags", "ban", "getBuyLinks", "getCorrection", "getFingerprintMetadata", "getInfo", "getShouts", "getSimilar", "getTags", "getTopFans", "getTopTags", "love", "removeTag", "scrobble", "search", "share", "unban", "unlove", "updateNowPlaying"])  __addTags__ addTags ∷ Artist → Track → [Tag] → APIKey → SessionKey → Secret → Lastfm Response
src/Network/Lastfm/XML/User.hs view
@@ -13,9 +13,10 @@ #include "user.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.User as API -$(xml ["getArtistTracks", "getBannedTracks", "getEvents", "getFriends", "getInfo", "getLovedTracks", "getNeighbours", "getNewReleases", "getPastEvents", "getPersonalTags", "getPlaylists", "getRecentStations", "getRecentTracks", "getRecommendedArtists", "getRecommendedEvents", "getShouts", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyChartList", "getWeeklyTrackChart", "shout"])+$(xmlWrapper ["getArtistTracks", "getBannedTracks", "getEvents", "getFriends", "getInfo", "getLovedTracks", "getNeighbours", "getNewReleases", "getPastEvents", "getPersonalTags", "getPlaylists", "getRecentStations", "getRecentTracks", "getRecommendedArtists", "getRecommendedEvents", "getShouts", "getTopAlbums", "getTopArtists", "getTopTags", "getTopTracks", "getWeeklyAlbumChart", "getWeeklyArtistChart", "getWeeklyChartList", "getWeeklyTrackChart", "shout"])  __getArtistTracks__ getArtistTracks ∷ User → Artist → Maybe StartTimestamp → Maybe EndTimestamp → Maybe Page → APIKey → Lastfm Response
src/Network/Lastfm/XML/Venue.hs view
@@ -9,9 +9,10 @@ #include "venue.docs"  import Network.Lastfm.Internal+import Network.Lastfm.XML (xmlWrapper) import qualified Network.Lastfm.API.Venue as API -$(xml ["getEvents", "getPastEvents", "search"])+$(xmlWrapper ["getEvents", "getPastEvents", "search"])  __getEvents__ getEvents ∷ Venue → Maybe FestivalsOnly → APIKey → Lastfm Response