diff options
Diffstat (limited to 'tv/5pkgs/haskell/th-env')
-rw-r--r-- | tv/5pkgs/haskell/th-env/default.nix | 10 | ||||
-rw-r--r-- | tv/5pkgs/haskell/th-env/src/THEnv.hs | 49 | ||||
-rw-r--r-- | tv/5pkgs/haskell/th-env/th-env.cabal | 20 |
3 files changed, 0 insertions, 79 deletions
diff --git a/tv/5pkgs/haskell/th-env/default.nix b/tv/5pkgs/haskell/th-env/default.nix deleted file mode 100644 index 158fb16..0000000 --- a/tv/5pkgs/haskell/th-env/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ mkDerivation, base, lib, template-haskell, text }: -mkDerivation { - pname = "th-env"; - version = "1.0.0"; - src = ./.; - libraryHaskellDepends = [ base template-haskell text ]; - homepage = "https://stackoverflow.com/q/57635686"; - license = "unknown"; - hydraPlatforms = lib.platforms.none; -} diff --git a/tv/5pkgs/haskell/th-env/src/THEnv.hs b/tv/5pkgs/haskell/th-env/src/THEnv.hs deleted file mode 100644 index b04f2ce..0000000 --- a/tv/5pkgs/haskell/th-env/src/THEnv.hs +++ /dev/null @@ -1,49 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -module THEnv - ( - -- * Compile-time configuration - lookupCompileEnv - , lookupCompileEnvExp - , getCompileEnv - , getCompileEnvExp - , fileAsString - ) where - -import Control.Monad -import qualified Data.Text as T -import qualified Data.Text.IO as T -import Language.Haskell.TH -import Language.Haskell.TH.Syntax (Lift(..)) -import System.Environment (getEnvironment) - --- Functions that work with compile-time configuration - --- | Looks up a compile-time environment variable. -lookupCompileEnv :: String -> Q (Maybe String) -lookupCompileEnv key = lookup key `liftM` runIO getEnvironment - --- | Looks up a compile-time environment variable. The result is a TH --- expression of type @Maybe String@. -lookupCompileEnvExp :: String -> Q Exp -lookupCompileEnvExp = (`sigE` [t| Maybe String |]) . lift <=< lookupCompileEnv - -- We need to explicly type the result so that things like `print Nothing` - -- work. - --- | Looks up an compile-time environment variable and fail, if it's not --- present. -getCompileEnv :: String -> Q String -getCompileEnv key = - lookupCompileEnv key >>= - maybe (fail $ "Environment variable " ++ key ++ " not defined") return - --- | Looks up an compile-time environment variable and fail, if it's not --- present. The result is a TH expression of type @String@. -getCompileEnvExp :: String -> Q Exp -getCompileEnvExp = lift <=< getCompileEnv - --- | Loads the content of a file as a string constant expression. --- The given path is relative to the source directory. -fileAsString :: FilePath -> Q Exp -fileAsString = do - -- addDependentFile path -- works only with template-haskell >= 2.7 - stringE . T.unpack . T.strip <=< runIO . T.readFile diff --git a/tv/5pkgs/haskell/th-env/th-env.cabal b/tv/5pkgs/haskell/th-env/th-env.cabal deleted file mode 100644 index b9a2cff..0000000 --- a/tv/5pkgs/haskell/th-env/th-env.cabal +++ /dev/null @@ -1,20 +0,0 @@ -name: th-env -version: 1.0.0 --- license: https://creativecommons.org/licenses/by-sa/4.0/ -license: OtherLicense -author: https://stackoverflow.com/users/9348482 -homepage: https://stackoverflow.com/q/57635686 -maintainer: tv <tv@krebsco.de> -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - build-depends: - base, - template-haskell, - text - exposed-modules: - THEnv - default-language: Haskell2010 - ghc-options: -O2 -Wall |