opt-env-conf-0.4.0.3: Settings parsing for Haskell: command-line arguments, environment variables, and configuration values.
Safe HaskellSafe-Inferred
LanguageHaskell2010

OptEnvConf.Reader

Synopsis

Documentation

newtype Reader a Source #

Constructors

Reader 

Fields

Instances

Instances details
Applicative Reader Source # 
Instance details

Defined in OptEnvConf.Reader

Methods

pure :: a -> Reader a #

(<*>) :: Reader (a -> b) -> Reader a -> Reader b #

liftA2 :: (a -> b -> c) -> Reader a -> Reader b -> Reader c #

(*>) :: Reader a -> Reader b -> Reader b #

(<*) :: Reader a -> Reader b -> Reader a #

Functor Reader Source # 
Instance details

Defined in OptEnvConf.Reader

Methods

fmap :: (a -> b) -> Reader a -> Reader b #

(<$) :: a -> Reader b -> Reader a #

Monad Reader Source # 
Instance details

Defined in OptEnvConf.Reader

Methods

(>>=) :: Reader a -> (a -> Reader b) -> Reader b #

(>>) :: Reader a -> Reader b -> Reader b #

return :: a -> Reader a #

MonadReader String Reader Source # 
Instance details

Defined in OptEnvConf.Reader

Methods

ask :: Reader String #

local :: (String -> String) -> Reader a -> Reader a #

reader :: (String -> a) -> Reader a #

Common readers

str :: IsString s => Reader s Source #

Read a string as-is.

This is the reader you will want to use for reading a Value.

This is different from auto for strings because Read wants to parse quotes when parsing Strings.

auto :: Read a => Reader a Source #

Read via the Read instance

You cannot use this for bare strings, because Read for strings parses quotes.

exists :: Reader Bool Source #

Always return True

exists = Reader $ const $ pure True

Constructing your own reader

maybeReader :: (String -> Maybe a) -> Reader a Source #

Turn a Maybe parsing function into a Reader

eitherReader :: (String -> Either String a) -> Reader a Source #

Turn an Either parsing function into a Reader

API note: This is a forward-compatible alias for Reader.

Comma-separated readers

commaSeparated :: Reader a -> Reader (NonEmpty a) Source #

Turn a reader into one that parses comma separated values with that reader.

commaSeparatedList :: Reader a -> Reader [a] Source #

Like commaSeparated but uses a list type.

Note that this will never parse the empty list, so prefer commaSeparated if you want a more accurately typed function.

commaSeparatedSet :: Ord a => Reader a -> Reader (Set a) Source #

Like commaSeparated but uses a set type.

Note that this will never parse the empty list, so prefer commaSeparated if you want a more accurately typed function.

Note also that this function throws away any ordering information and ignores any duplicate values.

Internal

renderCommaSeparated :: NonEmpty String -> String Source #

Separate by commas and escape commas in values

parseCommaSeparated :: String -> NonEmpty String Source #

Parse comma separated string, ignore escaped commas