on master help sign in
executable-config: Add default implementation
0178facAli Abrar
lib/executable-config/lookup/src/Obelisk/ExecutableConfig.hs+8−1
@@ -1,6 +1,13 @@
1module Obelisk.ExecutableConfig (get) where
1module Obelisk.ExecutableConfig (get) where
2
2
3+import Control.Exception
3import Data.Text (Text)
4import 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
4
9
5get :: Text -> IO (Maybe Text)
10get :: 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)