libmpd-0.5.0: An MPD client library.ContentsIndex
Network.MPD.Core
Stabilityalpha
MaintainerJoachim Fasting <joachim.fasting@gmail.com>
Contents
Classes
Data types
Running
Interacting
Description
The core datatypes and operations are defined here, including the primary instance of the MonadMPD class, MPD.
Synopsis
class (Monad m, MonadError MPDError m) => MonadMPD m where
open :: m ()
close :: m ()
send :: String -> m ()
receive :: m [String]
getHandle :: m (Maybe Handle)
getPassword :: m Password
setPassword :: String -> m ()
getVersion :: m (Int, Int, Int)
data MPD a
data MPDError
= NoMPD
| TimedOut
| Unexpected String
| Custom String
| ACK ACKType String
data ACKType
= InvalidArgument
| InvalidPassword
| Auth
| UnknownCommand
| FileNotFound
| PlaylistMax
| System
| PlaylistLoad
| Busy
| NotPlaying
| FileExists
| UnknownACK
type Response = Either MPDError
type Host = String
type Port = Integer
type Password = String
withMPDEx :: Host -> Port -> Password -> MPD a -> IO (Response a)
getResponse :: MonadMPD m => String -> m [String]
kill :: MonadMPD m => m ()
Classes
class (Monad m, MonadError MPDError m) => MonadMPD m where
A typeclass to allow for multiple implementations of a connection to an MPD server.
Methods
open :: m ()
Open (or re-open) a connection to the MPD server.
close :: m ()
Close the connection.
send :: String -> m ()
Send a string to the server.
receive :: m [String]
Get response from the server.
getHandle :: m (Maybe Handle)
Get underlying Handle (or Nothing, if no connection is estabilished)
getPassword :: m Password
Produce a password to send to the server should it ask for one.
setPassword :: String -> m ()
Alters password to be sent to the server.
getVersion :: m (Int, Int, Int)
Get MPD protocol version
show/hide Instances
Data types
data MPD a

The main implementation of an MPD client. It actually connects to a server and interacts with it.

To use the error throwing/catching capabilities:

 import Control.Monad.Error (throwError, catchError)

To run IO actions within the MPD monad:

 import Control.Monad.Trans (liftIO)
show/hide Instances
data MPDError
The MPDError type is used to signal errors, both from the MPD and otherwise.
Constructors
NoMPDMPD not responding
TimedOutThe connection timed out
Unexpected StringMPD returned an unexpected response. This is a bug, either in the library or in MPD itself.
Custom StringUsed for misc. errors
ACK ACKType StringACK type and a message from the server
show/hide Instances
data ACKType
Represents various MPD errors (aka. ACKs).
Constructors
InvalidArgumentInvalid argument passed (ACK 2)
InvalidPasswordInvalid password supplied (ACK 3)
AuthAuthentication required (ACK 4)
UnknownCommandUnknown command (ACK 5)
FileNotFoundFile or directory not found ACK 50)
PlaylistMaxPlaylist at maximum size (ACK 51)
SystemA system error (ACK 52)
PlaylistLoadPlaylist loading failed (ACK 53)
BusyUpdate already running (ACK 54)
NotPlayingAn operation requiring playback got interrupted (ACK 55)
FileExistsFile already exists (ACK 56)
UnknownACKAn unknown ACK (aka. bug)
show/hide Instances
type Response = Either MPDError
A response is either an MPDError or some result.
type Host = String
type Port = Integer
type Password = String
Running
withMPDEx :: Host -> Port -> Password -> MPD a -> IO (Response a)
The most configurable API for running an MPD action.
Interacting
getResponse :: MonadMPD m => String -> m [String]
Send a command to the MPD server and return the result.
kill :: MonadMPD m => m ()
Kill the server. Obviously, the connection is then invalid.
Produced by Haddock version 2.7.2