@@ -76,6 +76,7 @@ module Graphics.Vty.Config
7676 , standardIOConfig
7777 , runParseConfig
7878 , parseConfigFile
79+ , defaultConfig
7980 )
8081where
8182
@@ -87,7 +88,6 @@ import Control.Exception (catch, IOException, Exception(..), throwIO)
8788import Control.Monad (liftM, guard, void)
8889
8990import qualified Data.ByteString as BS
90−import Data.Default
9191import Data.Monoid
9292import Data.Typeable (Typeable)
9393
@@ -146,8 +146,8 @@ data Config = Config
146146 , termName :: Maybe String
147147 } deriving (Show, Eq)
148148
149−instance Default Config where
150− def = mempty
149+defaultConfig :: Config
150+defaultConfig = mempty
151151
152152instance Monoid Config where
153153 mempty = Config
@@ -179,14 +179,14 @@ instance Monoid Config where
179179userConfig :: IO Config
180180userConfig = do
181181 configFile <- (mappend <$> getAppUserDataDirectory "vty" <*> pure "/config") >>= parseConfigFile
182− overrideConfig <- maybe (return def) parseConfigFile =<< getEnv "VTY_CONFIG_FILE"
182+ overrideConfig <- maybe (return defaultConfig) parseConfigFile =<< getEnv "VTY_CONFIG_FILE"
183183 let base = configFile <> overrideConfig
184184 mappend base <$> overrideEnvConfig
185185
186186overrideEnvConfig :: IO Config
187187overrideEnvConfig = do
188188 d <- getEnv "VTY_DEBUG_LOG"
189− return $ def { debugLog = d }
189+ return $ defaultConfig { debugLog = d }
190190
191191-- | Configures VTY using defaults suitable for terminals. This action
192192-- can raise 'VtyConfigurationError'.
@@ -196,7 +196,7 @@ standardIOConfig = do
196196 case mb of
197197 Nothing -> throwIO VtyMissingTermEnvVar
198198 Just t ->
199− return def
199+ return defaultConfig
200200 { vmin = Just 1
201201 , mouseMode = Just False
202202 , bracketedPasteMode = Just False
@@ -209,13 +209,13 @@ standardIOConfig = do
209209parseConfigFile :: FilePath -> IO Config
210210parseConfigFile path = do
211211 catch (runParseConfig path <$> BS.readFile path)
212− (\(_ :: IOException) -> return def)
212+ (\(_ :: IOException) -> return defaultConfig)
213213
214214runParseConfig :: String -> BS.ByteString -> Config
215215runParseConfig name cfgTxt =
216216 case runParser parseConfig () name cfgTxt of
217217 Right cfg -> cfg
218− Left{} -> def
218+ Left{} -> defaultConfig
219219
220220------------------------------------------------------------------------
221221
@@ -249,13 +249,13 @@ mapDecl = do
249249 bytes <- P.stringLiteral configLexer
250250 key <- parseValue
251251 modifiers <- parseValue
252− return def { inputMap = [(termIdent, bytes, EvKey key modifiers)] }
252+ return defaultConfig { inputMap = [(termIdent, bytes, EvKey key modifiers)] }
253253
254254debugLogDecl :: Parser Config
255255debugLogDecl = do
256256 "debugLog" <- P.identifier configLexer
257257 path <- P.stringLiteral configLexer
258− return def { debugLog = Just path }
258+ return defaultConfig { debugLog = Just path }
259259
260260ignoreLine :: Parser ()
261261ignoreLine = void $ manyTill anyChar newline
@@ -264,7 +264,7 @@ parseConfig :: Parser Config
264264parseConfig = liftM mconcat $ many $ do
265265 P.whiteSpace configLexer
266266 let directives = [try mapDecl, try debugLogDecl]
267− choice directives <|> (ignoreLine >> return def)
267+ choice directives <|> (ignoreLine >> return defaultConfig)
268268
269269class Parse a where parseValue :: Parser a
270270instance Parse Char where parseValue = P.charLiteral configLexer