Bryan O'Sullivan avatar 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.