-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Print currently playing MPD's song metadata and status as JSON @package mpd-current-json @version 1.1.0.2 module Paths_mpd_current_json version :: Version getBinDir :: IO FilePath getLibDir :: IO FilePath getDynLibDir :: IO FilePath getDataDir :: IO FilePath getLibexecDir :: IO FilePath getDataFileName :: FilePath -> IO FilePath getSysconfDir :: IO FilePath module Version versionStr :: [Char] progName :: [Char] module Options data Opts -- | Custom data record for storing Parser values Opts :: Integer -> String -> String -> (Type -> Type) -> Opts -- | MPD port to connect. [optPort] :: Opts -> Integer -- | MPD host address to connect. [optHost] :: Opts -> String -- | Plain text password to connect to MPD. [optPass] :: Opts -> String -- | Print program version. [optVersion] :: Opts -> Type -> Type -- | Run a program description. -- -- Parse command line arguments. Display help text and exit if any parse -- error occurs. execParser :: ParserInfo a -> IO a -- | Create a ParserPrefs given a modifier prefs :: PrefsMod -> ParserPrefs -- | Show the help text if the user enters only the program name or -- subcommand. -- -- This will suppress a "Missing:" error and show the full usage instead -- if a user just types the name of the program. showHelpOnEmpty :: PrefsMod optsParser :: Parser Opts optsParserInfo :: ParserInfo Opts module Main -- | Where the program connects to MPD and uses the helper functions to -- extract values, organize them into a list of key/value pairs, make -- them a Value using object, then encode it to a -- conventional JSON ByteString with encodePretty for the -- pretty-print version. main :: IO () -- | Extract a field from the returned MPD.Status data record. -- -- This takes an Either MPDError Status value and -- a field label function f as arguments. It returns Just (f -- st) if the input status is Right st, where st -- is the Status value. This function helps to extract a specific -- field from the MPD.Status data record by providing the -- corresponding field label function. If the input status "st" -- is not Right st, indicating an error, or the field label -- function is not applicable, it returns Nothing. getStatusItem :: Either MPDError Status -> (Status -> a) -> Maybe a -- | Either check for the returned value of currentSong, -- then call processSong or return Nothing. getTag :: Metadata -> Either a (Maybe Song) -> Maybe String -- | Use sgGetTag to extract a tag from a song, -- safely get only the head item of the returned Maybe list, -- then safely convert it to a string. processSong :: Metadata -> Maybe Song -> Maybe String -- | Safely get the head of a list. Same as headMay. headMay :: [a] -> Maybe a -- | Convert Value to String within a Maybe -- context. -- -- This Value is from MPD and is basically the same as a -- String but used internally to store metadata values. -- -- Example: -- --
--   processSong :: Metadata -> Maybe Song -> Maybe String
--   processSong _ Nothing = Nothing
--   processSong tag (Just song) = do
--     let tagVal = MPD.sgGetTag tag song
--     valueToStringMay =<< (headMay =<< tagVal)
--   
-- -- sgGetTag returns a Maybe [Value]. MPD also -- provides toString that can convert, along other types, a -- Value to a String. valueToStringMay :: Value -> Maybe String -- | Check if Maybe v exists and is of type expected by -- object as defined in Value, if it is return both the -- key and value within the Maybe context tied -- with .=. This gives support to 'optional' fields using -- catMaybes that discard Nothing values and is meant to -- prevent creating JSON key/value pairs with null values, e.g.: -- --
--   jsonTags = object . catMaybes $
--       [ "artist"  .=? artist
--       , "album"   .=? album
--       , "title"   .=? title
--       ]
--   
-- -- Where if a value on the right is Nothing that key/value pair -- will not be included in object because of catMaybes. (.=?) :: (KeyValue a, ToJSON v) => Key -> Maybe v -> Maybe a