Commits

Bryan O'Sullivan committed 4fea8a7

Add an empty Config, for convenience.

Comments (0)

Files changed (1)

Data/Configurator.hs

     -- * Loading configuration data
     , autoReload
     , autoConfig
+    , empty
     -- * Lookup functions
     , lookup
     , lookupDefault
 import Prelude hiding (catch, lookup)
 import System.Environment (getEnv)
 import System.IO (hPutStrLn, stderr)
+import System.IO.Unsafe (unsafePerformIO)
 import System.Posix.Types (EpochTime, FileOffset)
 import System.PosixCompat.Files (fileSize, getFileStatus, modificationTime)
 import qualified Data.Attoparsec.Text as T
     forM_ (matching new) $ \(n',v) -> mapM_ (notify p n' (Just v)) acts
     forM_ (matching changedOrGone) $ \(n',v) -> mapM_ (notify p n' v) acts
 
+-- | A completely empty configuration.
+empty :: Config
+empty = unsafePerformIO $ do
+          m <- newIORef H.empty
+          s <- newIORef H.empty
+          return Config {
+                       cfgAuto = Nothing
+                     , cfgPaths = []
+                     , cfgMap = m
+                     , cfgSubs = s
+                     }
+{-# NOINLINE empty #-}
+
 -- $format
 --
 -- A configuration file consists of a series of directives and