envy
envy copied to clipboard
What is the proper way of grouping env vars into product Haskell types?
Hi! I'd like to know what is the proper way to group multiple independent env vars prefixed with a component name into a Haskell component structure that represent the component as a whole? Basically I want these vars
DB_NAME=
DB_PORT=
to be mapped into a single data DbSettings ...
, so that DbSettings
itself can be used in larger env var parsers like:
data AppSettings = AppSettings
{ something :: Text
, dbSettings :: DbSettings
}
Normally, I'd first define an instance of Var a
, but fromVar
is only provided with a single variable, not a set of items. Does it mean that I should omit declaring instances for Var a
and proceed with manual parsing inside instances of FromEnv a
?