{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Web.Last.Types where import Control.Monad.State import Control.Monad.Error {- An api key must be provided in order to do anything. A user is only needed for certain api calls, namely ones that actually involve any writes. -} data LastState = LastState {apiKey :: APIKey, secret :: Secret, tok :: Maybe Token} deriving (Show,Eq) type APIKey = String type Token = String type Secret = String newtype Last a = Last {lastM :: ErrorT String (StateT LastState IO) a} deriving (Monad,MonadIO,Functor,MonadState LastState, MonadError String) data User = User {userName :: String, password :: String} deriving (Eq,Show) data LastFMError = LastFMError {errorNo :: String, message :: String} deriving (Show,Eq) data TopTracks = TopTracks {trackCountry :: String, tracks :: [Ranked Track]} deriving (Eq,Show,Ord) data TopArtists = TopArtists {artistCountry :: String, artists :: [Ranked Artist]} deriving (Eq,Show,Ord) data Ranked a = Ranked String a -- !!! Read in a Int instead of a String deriving (Eq,Show,Ord) data Track = Track {trackName :: String, playCount :: String, trackMBID :: String, trackUrl :: String, streamable :: StreamProp, trackArtist :: Artist, trackImages :: [Image]} deriving (Eq,Show,Ord) data StreamProp = StreamProp String String -- Record? deriving (Eq,Show,Ord) data Artist = Artist {artistName :: String, artistMBID :: String, artistURL :: String} deriving (Eq,Show,Ord) data Image = Image {imageUrl :: String, size :: String} deriving (Eq,Show,Ord) data Events = Events {location :: String, events :: [Event], moreEvents :: Bool} -- want to handle this properly in geo.getEvents deriving (Show,Eq,Ord) data Event = Event {eventId :: String, title :: String, headliner :: String, otherArtist :: [String], venue :: Venue, startDate :: String, startTime :: Maybe String, -- How many other keys will have missing values? description :: String, eventImages :: [Image], attendance :: String, reviews :: String, tag :: String, eventUrl :: String} deriving (Show,Eq,Ord) data Venue = Venue {venueName :: String, venueLocation :: Location, venueUrl :: String} deriving (Show,Eq,Ord) data Location = Location {geoPoint :: GeoPoint, country :: String, city :: String, street :: String, postalcode :: String, timezone :: String} deriving (Show,Eq,Ord) data GeoPoint = GeoPoint {lat :: String, long :: String} deriving (Show,Eq,Ord) data Album = Album {albumName :: String, albumArtist :: String, albumID :: String, albumMBID :: String, albumUrl :: String, releaseDate :: String, albumImages :: [Image], listeners :: String, playcount :: String, toptags :: String, wiki :: AlbumWiki} deriving (Show,Eq,Ord) data AlbumWiki = AlbumWiki {published :: String, summary :: String, content :: String} deriving (Show,Eq,Ord) data OpenSearch a = OpenSearch {searchQuery :: Query, totalResults :: String, -- Would rather have an iterator style interface to paged results startIndex :: String, itemsPerPage :: String, results :: [a]} deriving (Show,Eq,Ord) data Query = Query {queryText :: String, role :: String, searchTerms :: String, startPage :: String} deriving (Show,Eq,Ord)