executable-config: Add default implementation
commit0178fac63c4b168b08f7d5d5f904a21a8633428d
authorAli Abrar <aliabrar@gmail.com>
dateThu 1 Mar 2018, 17:58 (9 years ago)
parent64624ba
lib/executable-config/lookup/src/Obelisk/ExecutableConfig.hs+8−1
@@ -1,6 +1,13 @@
11module Obelisk.ExecutableConfig (get) where
22
3+import Control.Exception
34import Data.Text (Text)
5+import Data.Text as T
6+import Data.Text.IO as T
7+import System.FilePath.Posix ((</>))
8+import System.IO.Error
49
510get :: Text -> IO (Maybe Text)
6−get _ = return Nothing
11+get path = do
12+ let doesNotExist = \e -> if isDoesNotExistError e then Just () else Nothing
13+ catchJust doesNotExist (fmap Just $ T.readFile $ "config" </> T.unpack path) (\_ -> pure Nothing)