on master help sign in
executable-config: Add stub ghc module
commit2c63e03b518eaaf8c0b7636b65b638c8a233d8a1 authorAli Abrar <aliabrar@gmail.com> dateMon 19 Feb 2018, 14:04 (9 years ago) parent9562b99
4 files changed+16−17
lib/executable-config/lookup/obelisk-executable-config.cabal+3−6 lib/executable-config/lookup/src-ios/Obelisk/ExecutableConfig.hs+7−2 lib/executable-config/lookup/src/Obelisk/ExecutableConfig.hs+6 lib/executable-config/lookup/src/Obelisk/ExecutableConfig/Internal.hs−9
lib/executable-config/lookup/obelisk-executable-config.cabal+3−6
@@ -19,11 +19,10 @@ flag ghcjs
1919 manual: True
2020
2121library
22− hs-source-dirs: src
22+ exposed-modules: Obelisk.ExecutableConfig
2323 if flag(ios)
2424 hs-source-dirs: src-ios
2525 build-depends: jsaddle-wkwebview
26− exposed-modules: Obelisk.ExecutableConfig
2726 else
2827 if flag(android)
2928 hs-source-dirs: src-android
@@ -31,12 +30,12 @@ library
3130 other-modules: Obelisk.ExecutableConfig.Internal.AssetManager
3231 build-depends: android-activity
3332 ld-options: -landroid
34− exposed-modules: Obelisk.ExecutableConfig
3533 else
3634 if flag(ghcjs)
3735 hs-source-dirs: src-ghcjs
3836 build-depends: ghcjs-dom
39− exposed-modules: Obelisk.ExecutableConfig
37+ else
38+ hs-source-dirs: src
4039
4140 build-depends:
4241 base,
@@ -44,5 +43,3 @@ library
4443 filepath,
4544 text,
4645 transformers
47−
48− other-modules: Obelisk.ExecutableConfig.Internal
lib/executable-config/lookup/src-ios/Obelisk/ExecutableConfig.hs+7−2
@@ -1,5 +1,6 @@
11module Obelisk.ExecutableConfig (get) where
22
3+import Control.Exception
34import Control.Monad
45import Control.Monad.Trans.Maybe
56import Data.ByteString as BS
@@ -9,9 +10,13 @@ import qualified Data.Text.IO as T
910import qualified Data.Text.Encoding as T
1011import Language.Javascript.JSaddle.WKWebView
1112import System.FilePath.Posix ((</>))
12−
13−import Obelisk.ExecutableConfig.Internal (catchDoesNotExist)
13+import System.IO.Error
1414
1515get :: Text -> IO (Maybe Text)
1616get name = fmap join $ mainBundleResourcePath >>= \mp -> forM mp $ \p ->
1717 catchDoesNotExist $ T.readFile $ T.unpack (T.decodeUtf8 p) </> "config" </> T.unpack name
18+
19+catchDoesNotExist :: IO a -> IO (Maybe a)
20+catchDoesNotExist f = catchJust doesNotExist (Just <$> f) $ const $ return Nothing
21+ where
22+ doesNotExist e = if isDoesNotExistError e then Just () else Nothing
lib/executable-config/lookup/src/Obelisk/ExecutableConfig.hsnew file+6
@@ -0,0 +1,6 @@
1+module Obelisk.ExecutableConfig (get) where
2+
3+import Data.Text (Text)
4+
5+get :: Text -> IO (Maybe Text)
6+get _ = return Nothing
lib/executable-config/lookup/src/Obelisk/ExecutableConfig/Internal.hsdeleted−9
@@ -1,9 +0,0 @@
1−module Obelisk.ExecutableConfig.Internal where
2−
3−import Control.Exception
4−import System.IO.Error
5−
6−catchDoesNotExist :: IO a -> IO (Maybe a)
7−catchDoesNotExist f = catchJust doesNotExist (Just <$> f) $ const $ return Nothing
8− where
9− doesNotExist e = if isDoesNotExistError e then Just () else Nothing