from-env-0.1.3.0: Provides a generic way to construct values from environment variables.
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Environment.FromEnv

Synopsis

Core class

class FromEnv a where Source #

Class for things that can be created from environment variables.

Minimal complete definition

Nothing

Methods

fromEnv :: MonadIO m => m (Either FromEnvError a) Source #

default fromEnv :: (MonadIO m, Generic a, GFromEnv' (Rep a)) => m (Either FromEnvError a) Source #

Instances

Instances details
(FromEnv a, FromEnv b) => FromEnv (a, b) Source # 
Instance details

Defined in System.Environment.FromEnv

Methods

fromEnv :: MonadIO m => m (Either FromEnvError (a, b)) Source #

(FromEnv a, FromEnv b, FromEnv c) => FromEnv (a, b, c) Source # 
Instance details

Defined in System.Environment.FromEnv

Methods

fromEnv :: MonadIO m => m (Either FromEnvError (a, b, c)) Source #

Options

defaultEnvOpts :: FromEnvOptions Source #

Default FromEnvOptions:

The default options will try to read a field name fieldName from an environment variables FIELD_NAME, as this is the most common naming convention for environment variables.

If you want different behavior, see gFromEnv.

FromEnvOptions
{ optsFieldLabelModifier = Just . screamingSnake
}

data FromEnvOptions Source #

Options to specify how to construct your datatype from environment variables. Options can be set using record update syntax and defaultEnvOpts.

Generic parsing class

class GFromEnv a where Source #

Minimal complete definition

Nothing

Methods

gFromEnv :: MonadIO m => FromEnvOptions -> m (Either FromEnvError a) Source #

Try to construct a value from environment variables.

default gFromEnv :: (MonadIO m, Generic a, GFromEnv' (Rep a)) => FromEnvOptions -> m (Either FromEnvError a) Source #

Instances

Instances details
(Generic a, GFromEnv' (Rep a)) => GFromEnv a Source # 
Instance details

Defined in System.Environment.FromEnv

Errors

data FromEnvError Source #

Constructors

UnsetVariable String

A field was unset in the environment

FailedToParse String String

Failed to parse a given field from an environment variable

AggregateError [FromEnvError]

There was more than one error.

Instances

Instances details
Show FromEnvError Source # 
Instance details

Defined in System.Environment.FromEnv

Eq FromEnvError Source # 
Instance details

Defined in System.Environment.FromEnv