envy-extensible- Provides FromEnv in envy instance for Record of extensible.

Copyright(c) 2020 IIJ Innovation Institute Inc.
MaintainerYAMAMOTO Yuji <yuji-yamamoto@iij.ad.jp>
Safe HaskellNone



Provides functions to create Record from environment variable using Parser.



recordFromEnvWithDefault :: forall (xs :: [Assoc Symbol Type]) h. Forall (KeyTargetAre KnownSymbol (Instance1 Var h)) xs => RecordOf h xs -> FieldLabelToEnvName -> Parser (RecordOf h xs) Source #

Parser for Record. This is necessary to implement the instance of FromEnv for Record correctly.

recordFromEnv :: forall (xs :: [Assoc Symbol Type]) h. Forall (KeyTargetAre KnownSymbol (Instance1 Var h)) xs => Parser (RecordOf h xs) Source #

recordFromEnv = recordFromEnvWith $ defaultFieldLabelToEnvName ""

type FieldLabelToEnvName = String -> String Source #

Function to convert field labels of Record into the name of environment variable. Applied to each field label before passing it to env

defaultFieldLabelToEnvName :: String -> FieldLabelToEnvName Source #

The default of FieldLabelToEnvName.

If the first argument is empty, just convert the field label (second argument) into UPPER_SNAKE_CASE.

>>> defaultFieldLabelToEnvName "" "thisIsATest"

Otherwise, convert the field label into UPPER_SNAKE_CASE, then prepend the first argument with an underscore _.

>>> defaultFieldLabelToEnvName "PREFIXED" "thisIsATest"

camelToUpperSnakeCase :: FieldLabelToEnvName Source #

Used internally in defaultFieldLabelToEnvName. Published for your convenience.