mr-env alternatives and similar packages
Based on the "System" category.
Alternatively, view mr-env alternatives based on common mentions on social networks and blogs.
-
ghc-hotswap
DISCONTINUED. Example code for how we swap compiled code within a running Haskell process. -
plugins
Dynamic linking and runtime evaluation of Haskell, and C, including dependency chasing and package resolution. -
ascii-progress
A simple Haskell progress bar for the console. Heavily borrows from TJ Holowaychuk's Node.JS project -
language-puppet
A library to work with Puppet manifests, test them and eventually replace everything ruby.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of mr-env or a related project?
README
Mr. Env
A simple way to read environment variables in Haskell.
-- Read environment variables, with defaults
host <- envAsString "HOST" "localhost"
port <- envAsInt "PORT" 8000
Simple Example
Read environment variables with do
notation:
import System.Environment.MrEnv ( envAsBool, envAsInt, envAsInteger, envAsString )
main :: IO ()
main = do
-- Get a string, with a fallback value if nothing is set.
host <- envAsString "HOST" "localhost"
-- Get an int. If you need an integer instead you could also use envAsInteger.
port <- envAsInt "PORT" 8000
-- Get a boolean. Here we're expecting the environment variable to read
-- something along the lines of "true", "TRUE", "True", "truE" and so on.
debug <- envAsBool "DEBUG" False
putStrLn $
"Let's connect to "
++ host
++ " on port "
++ show port
++ ". Debug mode is "
++ if debug then "on" else "off"
++ "."
Fancy Example
Read environment variables into a record:
import System.Environment.MrEnv ( envAsBool, envAsInt, envAsInteger, envAsString )
data Config =
Config { host :: String
, port :: Int
, debug :: Bool
}
getConfig :: IO Config
getConfig = Config
<$> envAsString "HOST" "localhost"
<*> envAsInt "PORT" 8000
<*> envAsBool "DEBUG" False
main :: IO ()
main =
getConfig >>= \conf ->
putStrLn $
"Let's connect to "
++ host conf
++ " on port "
++ show $ port conf
++ ". Debug mode is "
++ if debug conf then "on" else "off"
++ "."
We suggest pronouncing <*>
brackety-splat (as
opposed to ap). In that vein, <$>
is brackety-cash.
Authors
License
MIT
*Note that all licence references and agreements mentioned in the mr-env README section above
are relevant to that project's source code only.