module Effectful.Environment
(
Environment
, runEnvironment
, getArgs
, getProgName
, getExecutablePath
, getEnv
, getEnvironment
, lookupEnv
, setEnv
, unsetEnv
, withArgs
, withProgName
) where
import qualified System.Environment as E
import Effectful
import Effectful.Dispatch.Static
data Environment :: Effect
type instance DispatchOf Environment = Static WithSideEffects
data instance StaticRep Environment = Environment
runEnvironment :: IOE :> es => Eff (Environment : es) a -> Eff es a
runEnvironment :: forall (es :: [Effect]) a.
(IOE :> es) =>
Eff (Environment : es) a -> Eff es a
runEnvironment = forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(DispatchOf e ~ 'Static sideEffects, MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep StaticRep Environment
Environment
getArgs :: Environment :> es => Eff es [String]
getArgs :: forall (es :: [Effect]). (Environment :> es) => Eff es [String]
getArgs = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO [String]
E.getArgs
getEnv :: Environment :> es => String -> Eff es String
getEnv :: forall (es :: [Effect]).
(Environment :> es) =>
String -> Eff es String
getEnv = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO String
E.getEnv
getEnvironment :: Environment :> es => Eff es [(String, String)]
getEnvironment :: forall (es :: [Effect]).
(Environment :> es) =>
Eff es [(String, String)]
getEnvironment = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO [(String, String)]
E.getEnvironment
getExecutablePath :: Environment :> es => Eff es FilePath
getExecutablePath :: forall (es :: [Effect]). (Environment :> es) => Eff es String
getExecutablePath = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO String
E.getExecutablePath
getProgName :: Environment :> es => Eff es String
getProgName :: forall (es :: [Effect]). (Environment :> es) => Eff es String
getProgName = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ IO String
E.getProgName
lookupEnv :: Environment :> es => String -> Eff es (Maybe String)
lookupEnv :: forall (es :: [Effect]).
(Environment :> es) =>
String -> Eff es (Maybe String)
lookupEnv = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO (Maybe String)
E.lookupEnv
setEnv :: Environment :> es => String -> String -> Eff es ()
setEnv :: forall (es :: [Effect]).
(Environment :> es) =>
String -> String -> Eff es ()
setEnv String
n = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> IO ()
E.setEnv String
n
unsetEnv :: Environment :> es => String -> Eff es ()
unsetEnv :: forall (es :: [Effect]). (Environment :> es) => String -> Eff es ()
unsetEnv = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ()
E.unsetEnv
withArgs :: Environment :> es => [String] -> Eff es a -> Eff es a
withArgs :: forall (es :: [Effect]) a.
(Environment :> es) =>
[String] -> Eff es a -> Eff es a
withArgs = forall a b (es :: [Effect]).
HasCallStack =>
(IO a -> IO b) -> Eff es a -> Eff es b
unsafeLiftMapIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [String] -> IO a -> IO a
E.withArgs
withProgName :: Environment :> es => String -> Eff es a -> Eff es a
withProgName :: forall (es :: [Effect]) a.
(Environment :> es) =>
String -> Eff es a -> Eff es a
withProgName = forall a b (es :: [Effect]).
HasCallStack =>
(IO a -> IO b) -> Eff es a -> Eff es b
unsafeLiftMapIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. String -> IO a -> IO a
E.withProgName