{-# LANGUAGE FlexibleContexts, CPP #-}
------------------------------------------------------------------------------
-- |
-- Module: Xmobar.Config.Parse
-- Copyright: (c) 2018, 2020, 2022 Jose Antonio Ortega Ruiz
-- License: BSD3-style (see LICENSE)
--
-- Maintainer: jao@gnu.org
-- Stability: unstable
-- Portability: portable
-- Created: Sun Nov 25, 2018 23:56
--
--
-- Parsing of configuration files
--
------------------------------------------------------------------------------


module Xmobar.Config.Parse(readConfig, parseConfig) where

import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Number (int)
import Text.ParserCombinators.Parsec.Perm ((<|?>), (<$?>), permute)
import Control.Monad.IO.Class (liftIO)
import Data.Functor ((<&>))

import Xmobar.Config.Types

#if defined XFT || defined UTF8
import qualified System.IO as S (readFile)
#endif

readFileSafe :: FilePath -> IO String
#if defined XFT || defined UTF8
readFileSafe :: FilePath -> IO FilePath
readFileSafe = FilePath -> IO FilePath
S.readFile
#else
readFileSafe = readFile
#endif

stripComments :: String -> String
stripComments :: FilePath -> FilePath
stripComments =
  [FilePath] -> FilePath
unlines ([FilePath] -> FilePath)
-> (FilePath -> [FilePath]) -> FilePath -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath -> FilePath) -> [FilePath] -> [FilePath]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> FilePath -> FilePath
forall a. Int -> [a] -> [a]
drop Int
5 (FilePath -> FilePath)
-> (FilePath -> FilePath) -> FilePath -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> FilePath -> FilePath
strip Bool
False (FilePath -> FilePath)
-> (FilePath -> FilePath) -> FilePath -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Char -> FilePath
forall a. Int -> a -> [a]
replicate Int
5 Char
' 'FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++)) ([FilePath] -> [FilePath])
-> (FilePath -> [FilePath]) -> FilePath -> [FilePath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [FilePath]
lines
    where strip :: Bool -> FilePath -> FilePath
strip Bool
m (Char
'-':Char
'-':FilePath
xs) = if Bool
m then FilePath
"--" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ Bool -> FilePath -> FilePath
strip Bool
m FilePath
xs else FilePath
""
          strip Bool
m (Char
'"':FilePath
xs) = Char
'"'Char -> FilePath -> FilePath
forall a. a -> [a] -> [a]
: Bool -> FilePath -> FilePath
strip (Bool -> Bool
not Bool
m) FilePath
xs
          strip Bool
m (Char
x:FilePath
xs) = Char
x Char -> FilePath -> FilePath
forall a. a -> [a] -> [a]
: Bool -> FilePath -> FilePath
strip Bool
m FilePath
xs
          strip Bool
_ [] = []

-- | Parse the config, logging a list of fields that were missing and replaced
-- by the default definition.
parseConfig :: Config -> String -> Either ParseError (Config,[String])
parseConfig :: Config -> FilePath -> Either ParseError (Config, [FilePath])
parseConfig Config
defaultConfig =
  GenParser Char [FilePath] (Config, [FilePath])
-> [FilePath]
-> FilePath
-> FilePath
-> Either ParseError (Config, [FilePath])
forall tok st a.
GenParser tok st a
-> st -> FilePath -> [tok] -> Either ParseError a
runParser GenParser Char [FilePath] (Config, [FilePath])
parseConf [FilePath]
fields FilePath
"Config" (FilePath -> Either ParseError (Config, [FilePath]))
-> (FilePath -> FilePath)
-> FilePath
-> Either ParseError (Config, [FilePath])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> FilePath
stripComments
    where
      parseConf :: GenParser Char [FilePath] (Config, [FilePath])
parseConf = do
        ParsecT FilePath [FilePath] Identity Char
-> ParsecT FilePath [FilePath] Identity FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT FilePath [FilePath] Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space
        [FilePath] -> ParsecT FilePath [FilePath] Identity ()
forall u. [FilePath] -> ParsecT FilePath u Identity ()
sepEndSpc [FilePath
"Config",FilePath
"{"]
        Config
x <- Parsec FilePath [FilePath] Config
perms
        ParsecT FilePath [FilePath] Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
        [FilePath]
s <- ParsecT FilePath [FilePath] Identity [FilePath]
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
        (Config, [FilePath])
-> GenParser Char [FilePath] (Config, [FilePath])
forall (m :: * -> *) a. Monad m => a -> m a
return (Config
x, [FilePath]
s)

      perms :: Parsec FilePath [FilePath] Config
perms = StreamPermParser FilePath [FilePath] Config
-> Parsec FilePath [FilePath] Config
forall s tok st a.
Stream s Identity tok =>
StreamPermParser s st a -> Parsec s st a
permute (StreamPermParser FilePath [FilePath] Config
 -> Parsec FilePath [FilePath] Config)
-> StreamPermParser FilePath [FilePath] Config
-> Parsec FilePath [FilePath] Config
forall a b. (a -> b) -> a -> b
$ FilePath
-> [FilePath]
-> FilePath
-> FilePath
-> FilePath
-> FilePath
-> XPosition
-> Bool
-> TextOutputFormat
-> Int
-> [Int]
-> Int
-> Border
-> FilePath
-> Int
-> Int
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> FilePath
-> [Runnable]
-> FilePath
-> FilePath
-> FilePath
-> Bool
-> SignalChan
-> Config
Config
              (FilePath
 -> [FilePath]
 -> FilePath
 -> FilePath
 -> FilePath
 -> FilePath
 -> XPosition
 -> Bool
 -> TextOutputFormat
 -> Int
 -> [Int]
 -> Int
 -> Border
 -> FilePath
 -> Int
 -> Int
 -> Bool
 -> Bool
 -> Bool
 -> Bool
 -> Bool
 -> Bool
 -> FilePath
 -> [Runnable]
 -> FilePath
 -> FilePath
 -> FilePath
 -> Bool
 -> SignalChan
 -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     ([FilePath]
      -> FilePath
      -> FilePath
      -> FilePath
      -> FilePath
      -> XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok a b st.
Stream s Identity tok =>
(a -> b) -> (a, Parsec s st a) -> StreamPermParser s st b
<$?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pFont StreamPermParser
  FilePath
  [FilePath]
  ([FilePath]
   -> FilePath
   -> FilePath
   -> FilePath
   -> FilePath
   -> XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> ([FilePath], ParsecT FilePath [FilePath] Identity [FilePath])
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> FilePath
      -> FilePath
      -> FilePath
      -> XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> ([FilePath], ParsecT FilePath [FilePath] Identity [FilePath])
pFontList StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> FilePath
   -> FilePath
   -> FilePath
   -> XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> FilePath
      -> FilePath
      -> XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pWmClass StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> FilePath
   -> FilePath
   -> XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> FilePath
      -> XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pWmName
              StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> FilePath
   -> XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pBgColor StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (XPosition
      -> Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pFgColor StreamPermParser
  FilePath
  [FilePath]
  (XPosition
   -> Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (XPosition, Parsec FilePath [FilePath] XPosition)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (XPosition, Parsec FilePath [FilePath] XPosition)
pPosition
              StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (TextOutputFormat
      -> Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pTextOutput StreamPermParser
  FilePath
  [FilePath]
  (TextOutputFormat
   -> Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (TextOutputFormat, Parsec FilePath [FilePath] TextOutputFormat)
-> StreamPermParser
     FilePath
     [FilePath]
     (Int
      -> [Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (TextOutputFormat, Parsec FilePath [FilePath] TextOutputFormat)
pTextOutputFormat
              StreamPermParser
  FilePath
  [FilePath]
  (Int
   -> [Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Int, Parsec FilePath [FilePath] Int)
-> StreamPermParser
     FilePath
     [FilePath]
     ([Int]
      -> Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Int, Parsec FilePath [FilePath] Int)
pTextOffset StreamPermParser
  FilePath
  [FilePath]
  ([Int]
   -> Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> ([Int], Parsec FilePath [FilePath] [Int])
-> StreamPermParser
     FilePath
     [FilePath]
     (Int
      -> Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> ([Int], Parsec FilePath [FilePath] [Int])
pTextOffsets
              StreamPermParser
  FilePath
  [FilePath]
  (Int
   -> Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Int, Parsec FilePath [FilePath] Int)
-> StreamPermParser
     FilePath
     [FilePath]
     (Border
      -> FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Int, Parsec FilePath [FilePath] Int)
pIconOffset StreamPermParser
  FilePath
  [FilePath]
  (Border
   -> FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Border, Parsec FilePath [FilePath] Border)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Border, Parsec FilePath [FilePath] Border)
pBorder
              StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (Int
      -> Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pBdColor StreamPermParser
  FilePath
  [FilePath]
  (Int
   -> Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Int, Parsec FilePath [FilePath] Int)
-> StreamPermParser
     FilePath
     [FilePath]
     (Int
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Int, Parsec FilePath [FilePath] Int)
pBdWidth StreamPermParser
  FilePath
  [FilePath]
  (Int
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Int, Parsec FilePath [FilePath] Int)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Int, Parsec FilePath [FilePath] Int)
pAlpha StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pHideOnStart
              StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pAllDesktops StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pOverrideRedirect StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pPickBroadest
              StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (Bool
      -> FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pLowerOnStart StreamPermParser
  FilePath
  [FilePath]
  (Bool
   -> FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath
      -> [Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pPersistent StreamPermParser
  FilePath
  [FilePath]
  (FilePath
   -> [Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     ([Runnable]
      -> FilePath
      -> FilePath
      -> FilePath
      -> Bool
      -> SignalChan
      -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pIconRoot
              StreamPermParser
  FilePath
  [FilePath]
  ([Runnable]
   -> FilePath
   -> FilePath
   -> FilePath
   -> Bool
   -> SignalChan
   -> Config)
-> ([Runnable], Parsec FilePath [FilePath] [Runnable])
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath -> FilePath -> FilePath -> Bool -> SignalChan -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> ([Runnable], Parsec FilePath [FilePath] [Runnable])
pCommands StreamPermParser
  FilePath
  [FilePath]
  (FilePath -> FilePath -> FilePath -> Bool -> SignalChan -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath
     [FilePath]
     (FilePath -> FilePath -> Bool -> SignalChan -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pSepChar StreamPermParser
  FilePath
  [FilePath]
  (FilePath -> FilePath -> Bool -> SignalChan -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath [FilePath] (FilePath -> Bool -> SignalChan -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pAlignSep StreamPermParser
  FilePath [FilePath] (FilePath -> Bool -> SignalChan -> Config)
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
-> StreamPermParser
     FilePath [FilePath] (Bool -> SignalChan -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pTemplate
              StreamPermParser FilePath [FilePath] (Bool -> SignalChan -> Config)
-> (Bool, Parsec FilePath [FilePath] Bool)
-> StreamPermParser FilePath [FilePath] (SignalChan -> Config)
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (Bool, Parsec FilePath [FilePath] Bool)
pVerbose StreamPermParser FilePath [FilePath] (SignalChan -> Config)
-> (SignalChan, Parsec FilePath [FilePath] SignalChan)
-> StreamPermParser FilePath [FilePath] Config
forall s tok st a b.
Stream s Identity tok =>
StreamPermParser s st (a -> b)
-> (a, Parsec s st a) -> StreamPermParser s st b
<|?> (SignalChan, Parsec FilePath [FilePath] SignalChan)
forall b. (SignalChan, ParsecT FilePath [FilePath] Identity b)
pSignal

      fields :: [FilePath]
fields    = [ FilePath
"font", FilePath
"additionalFonts", FilePath
"bgColor", FilePath
"fgColor"
                  , FilePath
"wmClass", FilePath
"wmName", FilePath
"sepChar"
                  , FilePath
"alignSep" , FilePath
"border", FilePath
"borderColor" ,FilePath
"template"
                  , FilePath
"position" , FilePath
"textOffset", FilePath
"textOffsets", FilePath
"iconOffset"
                  , FilePath
"allDesktops", FilePath
"overrideRedirect", FilePath
"pickBroadest"
                  , FilePath
"hideOnStart", FilePath
"lowerOnStart", FilePath
"persistent", FilePath
"iconRoot"
                  , FilePath
"alpha", FilePath
"commands", FilePath
"verbose", FilePath
"signal", FilePath
"textOutput"
                  , FilePath
"textOutputFormat"
                  ]

      pTextOutput :: (Bool, Parsec FilePath [FilePath] Bool)
pTextOutput = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
textOutput FilePath
"textOutput"
      pTextOutputFormat :: (TextOutputFormat, Parsec FilePath [FilePath] TextOutputFormat)
pTextOutputFormat = (Config -> TextOutputFormat)
-> FilePath
-> (TextOutputFormat, Parsec FilePath [FilePath] TextOutputFormat)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> TextOutputFormat
textOutputFormat FilePath
"textOutputFormat"
      pFont :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pFont = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
font FilePath
"font"
      pFontList :: ([FilePath], ParsecT FilePath [FilePath] Identity [FilePath])
pFontList = (Config -> [FilePath])
-> FilePath
-> ([FilePath], ParsecT FilePath [FilePath] Identity [FilePath])
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity [FilePath])
strListField Config -> [FilePath]
additionalFonts FilePath
"additionalFonts"
      pWmClass :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pWmClass = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
wmClass FilePath
"wmClass"
      pWmName :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pWmName = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
wmName FilePath
"wmName"
      pBgColor :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pBgColor = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
bgColor FilePath
"bgColor"
      pFgColor :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pFgColor = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
fgColor FilePath
"fgColor"
      pBdColor :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pBdColor = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
borderColor FilePath
"borderColor"
      pSepChar :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pSepChar = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
sepChar FilePath
"sepChar"
      pAlignSep :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pAlignSep = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
alignSep FilePath
"alignSep"
      pTemplate :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pTemplate = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall a.
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> FilePath
template FilePath
"template"

      pTextOffset :: (Int, Parsec FilePath [FilePath] Int)
pTextOffset = (Config -> Int)
-> FilePath -> (Int, Parsec FilePath [FilePath] Int)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Int
textOffset FilePath
"textOffset"
      pTextOffsets :: ([Int], Parsec FilePath [FilePath] [Int])
pTextOffsets = (Config -> [Int])
-> FilePath -> ([Int], Parsec FilePath [FilePath] [Int])
forall a.
(Config -> a) -> FilePath -> (a, Parsec FilePath [FilePath] [Int])
readIntList Config -> [Int]
textOffsets FilePath
"textOffsets"
      pIconOffset :: (Int, Parsec FilePath [FilePath] Int)
pIconOffset = (Config -> Int)
-> FilePath -> (Int, Parsec FilePath [FilePath] Int)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Int
iconOffset FilePath
"iconOffset"
      pPosition :: (XPosition, Parsec FilePath [FilePath] XPosition)
pPosition = (Config -> XPosition)
-> FilePath -> (XPosition, Parsec FilePath [FilePath] XPosition)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> XPosition
position FilePath
"position"
      pHideOnStart :: (Bool, Parsec FilePath [FilePath] Bool)
pHideOnStart = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
hideOnStart FilePath
"hideOnStart"
      pLowerOnStart :: (Bool, Parsec FilePath [FilePath] Bool)
pLowerOnStart = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
lowerOnStart FilePath
"lowerOnStart"
      pPersistent :: (Bool, Parsec FilePath [FilePath] Bool)
pPersistent = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
persistent FilePath
"persistent"
      pBorder :: (Border, Parsec FilePath [FilePath] Border)
pBorder = (Config -> Border)
-> FilePath -> (Border, Parsec FilePath [FilePath] Border)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Border
border FilePath
"border"
      pBdWidth :: (Int, Parsec FilePath [FilePath] Int)
pBdWidth = (Config -> Int)
-> FilePath -> (Int, Parsec FilePath [FilePath] Int)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Int
borderWidth FilePath
"borderWidth"
      pAllDesktops :: (Bool, Parsec FilePath [FilePath] Bool)
pAllDesktops = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
allDesktops FilePath
"allDesktops"
      pOverrideRedirect :: (Bool, Parsec FilePath [FilePath] Bool)
pOverrideRedirect = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
overrideRedirect FilePath
"overrideRedirect"
      pPickBroadest :: (Bool, Parsec FilePath [FilePath] Bool)
pPickBroadest = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
pickBroadest FilePath
"pickBroadest"
      pIconRoot :: (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
pIconRoot = (Config -> FilePath)
-> FilePath
-> (FilePath, ParsecT FilePath [FilePath] Identity FilePath)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> FilePath
iconRoot FilePath
"iconRoot"
      pAlpha :: (Int, Parsec FilePath [FilePath] Int)
pAlpha = (Config -> Int)
-> FilePath -> (Int, Parsec FilePath [FilePath] Int)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Int
alpha FilePath
"alpha"
      pVerbose :: (Bool, Parsec FilePath [FilePath] Bool)
pVerbose = (Config -> Bool)
-> FilePath -> (Bool, Parsec FilePath [FilePath] Bool)
forall b a.
Read b =>
(Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> Bool
verbose FilePath
"verbose"

      pSignal :: (SignalChan, ParsecT FilePath [FilePath] Identity b)
pSignal = (Config -> SignalChan)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (SignalChan, ParsecT FilePath [FilePath] Identity b)
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> SignalChan
signal FilePath
"signal" (ParsecT FilePath [FilePath] Identity b
 -> (SignalChan, ParsecT FilePath [FilePath] Identity b))
-> ParsecT FilePath [FilePath] Identity b
-> (SignalChan, ParsecT FilePath [FilePath] Identity b)
forall a b. (a -> b) -> a -> b
$
        FilePath -> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
"signal is meant for use with Xmobar as a library.\n It is not meant for use in the configuration file."

      pCommands :: ([Runnable], Parsec FilePath [FilePath] [Runnable])
pCommands = (Config -> [Runnable])
-> FilePath
-> Parsec FilePath [FilePath] [Runnable]
-> ([Runnable], Parsec FilePath [FilePath] [Runnable])
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> [Runnable]
commands FilePath
"commands" Parsec FilePath [FilePath] [Runnable]
forall u. ParsecT FilePath u Identity [Runnable]
readCommands

      staticPos :: ParsecT FilePath u Identity FilePath
staticPos = do FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"Static"
                     ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip (FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"{")
                     FilePath
p <- ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (FilePath -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"}")
                     ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip (FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"}")
                     FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
","
                     FilePath -> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return (FilePath
"Static {"  FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
p  FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
"}")
      tillFieldEnd :: ParsecT FilePath u Identity FilePath
tillFieldEnd = ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
staticPos ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (FilePath -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m Char
noneOf FilePath
",}\n\r")

      commandsEnd :: ParsecT FilePath u Identity FilePath
commandsEnd  = ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip (FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"]") ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"}" ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
notNextRun)
      notNextRun :: ParsecT FilePath u Identity FilePath
notNextRun = do {FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
","
                      ; ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (ParsecT FilePath u Identity FilePath
 -> ParsecT FilePath u Identity ())
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity ()
forall a b. (a -> b) -> a -> b
$ ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip (ParsecT FilePath u Identity FilePath
 -> ParsecT FilePath u Identity FilePath)
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall a b. (a -> b) -> a -> b
$ FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"Run"
                      ; FilePath -> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
","
                      }
      readCommands :: ParsecT FilePath u Identity [Runnable]
readCommands = ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT FilePath u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar (ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall tok st a. GenParser tok st a -> GenParser tok st a
try ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
commandsEnd) ParsecT FilePath u Identity FilePath
-> (FilePath -> ParsecT FilePath u Identity [Runnable])
-> ParsecT FilePath u Identity [Runnable]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
                        FilePath -> FilePath -> ParsecT FilePath u Identity [Runnable]
forall a (m :: * -> *).
(Read a, MonadFail m) =>
FilePath -> FilePath -> m a
read' FilePath
commandsErr (FilePath -> ParsecT FilePath u Identity [Runnable])
-> (FilePath -> FilePath)
-> FilePath
-> ParsecT FilePath u Identity [Runnable]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FilePath -> FilePath -> FilePath)
-> FilePath -> FilePath -> FilePath
forall a b c. (a -> b -> c) -> b -> a -> c
flip FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
(++) FilePath
"]"
      strField :: (Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity FilePath)
strField Config -> a
e FilePath
n = (Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity FilePath
-> (a, ParsecT FilePath [FilePath] Identity FilePath)
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> a
e FilePath
n ParsecT FilePath [FilePath] Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
strMulti

      strMulti :: ParsecT FilePath u Identity FilePath
strMulti = Char -> ParsecT FilePath u Identity FilePath
forall u. Char -> ParsecT FilePath u Identity FilePath
scan Char
'"'
          where
            scan :: Char -> ParsecT FilePath u Identity FilePath
scan Char
lead = do
                ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
                Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
lead
                FilePath
s <- ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT FilePath u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar (ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
rowCont ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
unescQuote)
                (Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'"' ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> FilePath -> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
s) ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (FilePath -> FilePath)
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (FilePath
s FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++) (Char -> ParsecT FilePath u Identity FilePath
scan Char
'\\')
            rowCont :: GenParser Char st FilePath
rowCont    = GenParser Char st FilePath -> GenParser Char st FilePath
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char st FilePath -> GenParser Char st FilePath)
-> GenParser Char st FilePath -> GenParser Char st FilePath
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT FilePath st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\\' ParsecT FilePath st Identity Char
-> GenParser Char st FilePath -> GenParser Char st FilePath
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> FilePath -> GenParser Char st FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\n"
            unescQuote :: ParsecT FilePath u Identity FilePath
unescQuote = ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (FilePath -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"\\") ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\"")

      strListField :: (Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity [FilePath])
strListField Config -> a
e FilePath
n = (Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity [FilePath]
-> (a, ParsecT FilePath [FilePath] Identity [FilePath])
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> a
e FilePath
n ParsecT FilePath [FilePath] Identity [FilePath]
forall u. ParsecT FilePath u Identity [FilePath]
strList
      strList :: ParsecT FilePath u Identity [FilePath]
strList = do
        ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'['
        [FilePath]
list <- ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity [FilePath]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy (ParsecT FilePath u Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
strMulti ParsecT FilePath u Identity FilePath
-> (FilePath -> ParsecT FilePath u Identity FilePath)
-> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \FilePath
x -> ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces ParsecT FilePath u Identity ()
-> ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> FilePath -> ParsecT FilePath u Identity FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
x) (Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',')
        ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
        [FilePath] -> ParsecT FilePath u Identity [FilePath]
forall (m :: * -> *) a. Monad m => a -> m a
return [FilePath]
list

      wrapSkip :: ParsecT s u m b -> ParsecT s u m b
wrapSkip   ParsecT s u m b
x = ParsecT s u m Char -> ParsecT s u m FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT s u m Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space ParsecT s u m FilePath -> ParsecT s u m b -> ParsecT s u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT s u m b
x ParsecT s u m b -> (b -> ParsecT s u m b) -> ParsecT s u m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \b
r -> ParsecT s u m Char -> ParsecT s u m FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT s u m Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space ParsecT s u m FilePath -> ParsecT s u m b -> ParsecT s u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> b -> ParsecT s u m b
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
      sepEndSpc :: [FilePath] -> ParsecT FilePath u Identity ()
sepEndSpc    = (FilePath -> ParsecT FilePath u Identity FilePath)
-> [FilePath] -> ParsecT FilePath u Identity ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip (ParsecT FilePath u Identity FilePath
 -> ParsecT FilePath u Identity FilePath)
-> (FilePath -> ParsecT FilePath u Identity FilePath)
-> FilePath
-> ParsecT FilePath u Identity FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT FilePath u Identity FilePath
-> ParsecT FilePath u Identity FilePath
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT FilePath u Identity FilePath
 -> ParsecT FilePath u Identity FilePath)
-> (FilePath -> ParsecT FilePath u Identity FilePath)
-> FilePath
-> ParsecT FilePath u Identity FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> ParsecT FilePath u Identity FilePath
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m FilePath
string)
      fieldEnd :: ParsecT FilePath u Identity FilePath
fieldEnd     = ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT FilePath u Identity Char
 -> ParsecT FilePath u Identity FilePath)
-> ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity FilePath
forall a b. (a -> b) -> a -> b
$ ParsecT FilePath u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> FilePath -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
FilePath -> ParsecT s u m Char
oneOf FilePath
",}"
      field :: (Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field  Config -> a
e FilePath
n ParsecT FilePath [FilePath] Identity b
c = (,) (Config -> a
e Config
defaultConfig) (ParsecT FilePath [FilePath] Identity b
 -> (a, ParsecT FilePath [FilePath] Identity b))
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
forall a b. (a -> b) -> a -> b
$
                     ([FilePath] -> [FilePath])
-> ParsecT FilePath [FilePath] Identity ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((FilePath -> Bool) -> [FilePath] -> [FilePath]
forall a. (a -> Bool) -> [a] -> [a]
filter (FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
/= FilePath
n)) ParsecT FilePath [FilePath] Identity ()
-> ParsecT FilePath [FilePath] Identity ()
-> ParsecT FilePath [FilePath] Identity ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [FilePath] -> ParsecT FilePath [FilePath] Identity ()
forall u. [FilePath] -> ParsecT FilePath u Identity ()
sepEndSpc [FilePath
n,FilePath
"="] ParsecT FilePath [FilePath] Identity ()
-> ParsecT FilePath [FilePath] Identity b
-> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
                     ParsecT FilePath [FilePath] Identity b
-> ParsecT FilePath [FilePath] Identity b
forall s (m :: * -> *) u b.
Stream s m Char =>
ParsecT s u m b -> ParsecT s u m b
wrapSkip ParsecT FilePath [FilePath] Identity b
c ParsecT FilePath [FilePath] Identity b
-> (b -> ParsecT FilePath [FilePath] Identity b)
-> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \b
r -> ParsecT FilePath [FilePath] Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
fieldEnd ParsecT FilePath [FilePath] Identity FilePath
-> ParsecT FilePath [FilePath] Identity b
-> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> b -> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a. Monad m => a -> m a
return b
r
      readField :: (Config -> a)
-> FilePath -> (a, ParsecT FilePath [FilePath] Identity b)
readField Config -> a
a FilePath
n = (Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> a
a FilePath
n (ParsecT FilePath [FilePath] Identity b
 -> (a, ParsecT FilePath [FilePath] Identity b))
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
forall a b. (a -> b) -> a -> b
$ ParsecT FilePath [FilePath] Identity FilePath
forall u. ParsecT FilePath u Identity FilePath
tillFieldEnd ParsecT FilePath [FilePath] Identity FilePath
-> (FilePath -> ParsecT FilePath [FilePath] Identity b)
-> ParsecT FilePath [FilePath] Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FilePath -> FilePath -> ParsecT FilePath [FilePath] Identity b
forall a (m :: * -> *).
(Read a, MonadFail m) =>
FilePath -> FilePath -> m a
read' FilePath
n

      readIntList :: (Config -> a) -> FilePath -> (a, Parsec FilePath [FilePath] [Int])
readIntList Config -> a
d FilePath
n = (Config -> a)
-> FilePath
-> Parsec FilePath [FilePath] [Int]
-> (a, Parsec FilePath [FilePath] [Int])
forall a b.
(Config -> a)
-> FilePath
-> ParsecT FilePath [FilePath] Identity b
-> (a, ParsecT FilePath [FilePath] Identity b)
field Config -> a
d FilePath
n Parsec FilePath [FilePath] [Int]
forall u. ParsecT FilePath u Identity [Int]
intList
      intList :: ParsecT FilePath u Identity [Int]
intList = do
        ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'['
        [Int]
list <- ParsecT FilePath u Identity Int
-> ParsecT FilePath u Identity Char
-> ParsecT FilePath u Identity [Int]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy (ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces ParsecT FilePath u Identity ()
-> ParsecT FilePath u Identity Int
-> ParsecT FilePath u Identity Int
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT FilePath u Identity Int
forall i st. Integral i => CharParser st i
int ParsecT FilePath u Identity Int
-> (Int -> ParsecT FilePath u Identity Int)
-> ParsecT FilePath u Identity Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x-> ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces ParsecT FilePath u Identity ()
-> ParsecT FilePath u Identity Int
-> ParsecT FilePath u Identity Int
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> ParsecT FilePath u Identity Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
x) (Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',')
        ParsecT FilePath u Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Char -> ParsecT FilePath u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
        [Int] -> ParsecT FilePath u Identity [Int]
forall (m :: * -> *) a. Monad m => a -> m a
return [Int]
list

      read' :: FilePath -> FilePath -> m a
read' FilePath
d FilePath
s = case ReadS a
forall a. Read a => ReadS a
reads FilePath
s of
                    [(a
x, FilePath
_)] -> a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
                    [(a, FilePath)]
_ -> FilePath -> m a
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail (FilePath -> m a) -> FilePath -> m a
forall a b. (a -> b) -> a -> b
$ FilePath
"error reading the " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
d FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
" field: " FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++ FilePath
s

commandsErr :: String
commandsErr :: FilePath
commandsErr = FilePath
"commands: this usually means that a command could not" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
              FilePath
"\nbe parsed." FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
              FilePath
"\nThe error could be located at the begining of the command" FilePath -> FilePath -> FilePath
forall a. [a] -> [a] -> [a]
++
              FilePath
"\nwhich follows the offending one."

-- | Reads the configuration from a file or an error if it cannot be
-- parsed.
readConfig :: Config -> FilePath -> IO (Either ParseError (Config,[String]))
readConfig :: Config -> FilePath -> IO (Either ParseError (Config, [FilePath]))
readConfig Config
defaultConfig FilePath
f =
  IO FilePath -> IO FilePath
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FilePath -> IO FilePath
readFileSafe FilePath
f) IO FilePath
-> (FilePath -> Either ParseError (Config, [FilePath]))
-> IO (Either ParseError (Config, [FilePath]))
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> Config -> FilePath -> Either ParseError (Config, [FilePath])
parseConfig Config
defaultConfig