harg-0.5.0.0: Haskell program configuration using higher kinded data
Safe HaskellNone
LanguageHaskell2010

Options.Harg

Synopsis

Summary

harg is a wrapper around optparse-applicative that allows blending command-line configuration with environment variables, defaults as well as other sources such as JSON or YAML files. Here are some very simple examples:

  • Flat configuration type
  data Config
    = Config
        { host :: String
        , port :: Int
        , log  :: Bool
        , dir  :: Maybe String
        }

  -- Using HKD from higgledy
  configOpt :: HKD Config Opt
  configOpt
    = build @Config hostOpt portOpt logOpt dirOpt
    where
      hostOpt
        = optionWith strParser
            ( long "host"
            . short 'h'
            . help "Hostname"
            . envVar "HOST_NAME"
            )
      portOpt
        = optionWith readParser
            ( long "port"
            . short 'p'
            . help "Port number"
            . defaultVal 5432
            )
      logOpt
        = switchWith
            ( long "log"
            . help "Whether to log or not"
            )
      dirOpt
        = argumentWith strParser
            ( help "Some directory"
            . envVar "SOME_DIR"
            . optional
            )

  main :: IO Config
  main = do
    result <- execOpt defaultSources configOpt
    pure $ runIdentity (construct result)

The above could also be:

  type ConfigOpt
    =  Single String
    :* Single Int
    :* Single Bool
    :* Single String

  configOpt :: ConfigOpt Opt
  configOpt
    = hostOpt :* portOpt :* logOpt :* dirOpt
    where
      ...

  main :: IO Config
  main = do
    host :* port :* log :* dir <- execOpt defaultSources configOpt
    pure
      $ runIdentity
      $ Config
      <$> getSingle host
      <*> getSingle port
      <*> getSingle log
      <*> getSingle dir
  • Nested configuration type
  data Config
    = Config
        { dbConfig :: DbConfig
        , serverConfig :: ServerConfig
        }

  data DbConfig
    = DbConfig
        { dbHost :: String
        , dbPort :: Int
        }

  data ServerConfig
    = ServerConfig
        { srvPort :: Int
        , srvLog  :: Bool
        }

  type ConfigOpt
    =  HKD DbConfig
    :* HKD ServerConfig

  configOpt :: ConfigOpt Opt
  configOpt
    = dbOpt :* srvOpt
    where
      dbOpt = build DbConfig ...
      srvOpt = build ServerConfig ...

  main :: IO Config
  main = do
    db :* srv <- execOpt defaultSources configOpt
    pure
      $ runIdentity
      $ Config
      <$> construct db
      <*> construct srv
  • Subparsers
  data OneConfig = OneConfig ...
  data OtherConfig = OtherConfig ...

  data Config
    =  "one" :-> OneConfig
    :+ "other" :-> OtherConfig

  configOpt :: Config Opt
  configOpt
    = oneOpt :+ otherOpt :+ ANil
    where
      oneOpt = ...
      otherOpt = ...

  main :: IO ()
  main = do
    result <- execOpt defaultSources configOpt
    case result of
      HereF one            -> runWithOne one
      ThereF (HereF other) -> runWithOther other
    where
      runWithOne :: One -> IO ()
      runWithOne = ...
      runWithOther :: Other -> IO ()
      runWithOther = ...

TODO: more (and better) examples

Option declaration

option :: OptReader a -> (OptionOpt '[] a -> OptionOpt attr b) -> Opt b Source #

Create an option parser, equivalent to option. The second argument is the modifiers to add to the option, and can be defined by using function composition (.).

  someOption :: Opt Int
  someOption
    = option readParser
        ( long "someopt"
        . help "Some option"
        . defaultVal 256
        )

flag Source #

Arguments

:: a

Default value

-> a

Active value

-> (FlagOpt '[] a -> FlagOpt attr b) 
-> Opt b 

Create a flag parser, equivalent to option. The first argument is the default value (returned when the flag modifier is absent), and the second is the active value (returned when the flag modifier is present). The second argument is the modifiers to add to the option, and can be defined by using function composition (.).

  someFlag :: Opt Int
  someFlag
    = flag 0 1
        ( long "someflag"
        . help "Some flag"
        )

switch :: (FlagOpt '[] Bool -> FlagOpt attr Bool) -> Opt Bool Source #

A flag parser, specialized to Bool. The parser (e.g. when parsing an environment variable) will accept true and false, but case insensitive, rather than using the Read instance for Bool. The default value is False, and the active value is True.

  someSwitch :: Opt Bool
  someSwitch
    = switch
        ( long "someswitch"
        . help "Some switch"
        )

switch' :: (FlagOpt '[] Bool -> FlagOpt attr Bool) -> Opt Bool Source #

Similar to switch, but the default value is True and the active is False.

argument :: OptReader a -> (ArgumentOpt '[] a -> ArgumentOpt attr b) -> Opt b Source #

Create an argument parser, equivalent to argument. The second argument is the modifiers to add to the option, and can be defined by using function composition (.).

  someArgument :: Opt Int
  someArgument
    = argument
        ( help "Some argument"
        . defaultVal "this is the default"
        )

newtype Single (a :: Type) (f :: Type -> Type) Source #

Single a f is a newtype around f a, which allows mixing non-nested with nested values when creating configuration parsers, using :*.

  data User = User { name :: String, age :: Int }
    deriving Generic

  myConfig :: (Nested User :* Single Int) Opt
  myConfig
    =  nested @User nameOpt ageOpt
    :* single intOpt
    where
      ...

Constructors

Single 

Fields

Instances

Instances details
ApplicativeB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

bpure :: (forall (a0 :: k). f a0) -> Single a f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Single a f -> Single a g -> Single a (Product f g)

FunctorB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> Single a f -> Single a g

TraversableB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> Single a f -> e (Single a g)

(Show a, Show (f a)) => Show (Single a f) Source # 
Instance details

Defined in Options.Harg.Single

Methods

showsPrec :: Int -> Single a f -> ShowS #

show :: Single a f -> String #

showList :: [Single a f] -> ShowS #

Generic (f a) => Generic (Single a f) Source # 
Instance details

Defined in Options.Harg.Single

Associated Types

type Rep (Single a f) :: Type -> Type #

Methods

from :: Single a f -> Rep (Single a f) x #

to :: Rep (Single a f) x -> Single a f #

FromJSON (f a) => FromJSON (Single a f) Source # 
Instance details

Defined in Options.Harg.Single

Methods

parseJSON :: Value -> Parser (Single a f) #

parseJSONList :: Value -> Parser [Single a f] #

type Rep (Single a f) Source # 
Instance details

Defined in Options.Harg.Single

type Rep (Single a f) = Rep (f a)

single :: f a -> Single a f Source #

Wrap a value into a Single.

fromSingle :: Single a Identity -> a Source #

Helper for when f ~ Identity

newtype Nested (b :: Type) (f :: Type -> Type) Source #

Newtype wrapper around HKD.

Constructors

Nested (HKD b f) 

Instances

Instances details
ApplicativeB (HKD b) => ApplicativeB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

bpure :: (forall (a :: k). f a) -> Nested b f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Nested b f -> Nested b g -> Nested b (Product f g)

FunctorB (HKD b) => FunctorB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

bmap :: (forall (a :: k). f a -> g a) -> Nested b f -> Nested b g

TraversableB (HKD b) => TraversableB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> Nested b f -> e (Nested b g)

Generic (HKD b f) => Generic (Nested b f) Source # 
Instance details

Defined in Options.Harg.Nested

Associated Types

type Rep (Nested b f) :: Type -> Type #

Methods

from :: Nested b f -> Rep (Nested b f) x #

to :: Rep (Nested b f) x -> Nested b f #

FromJSON (HKD b f) => FromJSON (Nested b f) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

parseJSON :: Value -> Parser (Nested b f) #

parseJSONList :: Value -> Parser [Nested b f] #

type Rep (Nested b f) Source # 
Instance details

Defined in Options.Harg.Nested

type Rep (Nested b f) = Rep (HKD b f)

getNested :: Construct f b => Nested b f -> f b Source #

See documentation for construct

  data User = User { name :: String, age :: Int }
    deriving Generic

  getUserBack :: Maybe User
  getUserBack
    = getNested hkdUser
    where
      hkdUser :: Nested User Maybe
      hkdUser
        = nested @User (Just Joe) (Just 30)

nested :: forall b f k. (Build b f k, Coercible (HKD b f) (Nested b f), Coercible k (Nest k f)) => Nest k f Source #

See documentation for build

  data User = User { name :: String, age :: Int }
    deriving Generic

  someNestedValue :: Nested User Maybe
  someNestedValue
    = nested @User (Just Joe) (Just 30)

fromNested :: Construct Identity b => Nested b Identity -> b Source #

Helper for when f ~ Identity

data AssocListF (ts :: [Symbol]) (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where Source #

A heterogeneous list that holds higher-kinded types and the associated type constructor, along with a type level list of Symbols that act as tags for each type.

Constructors

ANil :: AssocListF '[] '[] f 
ACons :: x f -> AssocListF ts xs f -> AssocListF (t ': ts) (x ': xs) f 

type family l :+ r = (res :: (Type -> Type) -> Type) where ... infixr 4 Source #

Helper type-level function to construct an AssocList which is not yet applied to the type constructor that needs to be fully applied.

  type Config
    =  "run" :-> RunConfig
    :+ "test" :-> TestConfig

Config above has type (Type -> Type) -> Type, and requires a type like Opt to be fully applied.

Equations

(tl :-> vl) :+ (tr :-> vr) = AssocListF '[tl, tr] '[vl, vr] 
(tl :-> vl) :+ (AssocListF ts vs) = AssocListF (tl ': ts) (vl ': vs) 
l :+ r = TypeError ((('Text "Invalid type for tagged options. Construct like this:" :$$: 'Text "type MyConfig") :$$: 'Text " = \"one\" :-> ConfigForOne") :$$: 'Text " :+ \"two\" :-> ConfigForTwo") 

pattern (:+) :: x f -> AssocListF ts xs f -> AssocListF (t ': ts) (x ': xs) f infixr 4 Source #

data (t :: Symbol) :-> (v :: (Type -> Type) -> Type) :: (Type -> Type) -> Type infixr 5 Source #

data ((a :: (Type -> Type) -> Type) :* (b :: (Type -> Type) -> Type)) (f :: Type -> Type) infixr 4 Source #

Infix version of Product. Allows to combine higher-kinded types, and keep them partially applied until needed:

  data User = User { name :: String, age :: Int }
    deriving Generic

  type Config = Nested User :* Single Int

  configOpt :: Config Opt
  configOpt = ...

Constructors

(a f) :* (b f) infixr 4 

Instances

Instances details
(ApplicativeB a, ApplicativeB b) => ApplicativeB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bpure :: (forall (a0 :: k). f a0) -> (a :* b) f

bprod :: forall (f :: k -> Type) (g :: k -> Type). (a :* b) f -> (a :* b) g -> (a :* b) (Product f g)

(FunctorB a, FunctorB b) => FunctorB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> (a :* b) f -> (a :* b) g

(TraversableB a, TraversableB b) => TraversableB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> (a :* b) f -> e ((a :* b) g)

(GetSource l f, GetSource r f) => GetSource (l :* r) f Source # 
Instance details

Defined in Options.Harg.Sources.Types

Associated Types

type SourceVal (l :* r) Source #

Methods

getSource :: HargCtx -> (l :* r) f -> IO (SourceVal (l :* r)) Source #

(Show (a Identity), Show (b Identity)) => Show ((a :* b) Identity) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

showsPrec :: Int -> (a :* b) Identity -> ShowS #

show :: (a :* b) Identity -> String #

showList :: [(a :* b) Identity] -> ShowS #

Generic ((a :* b) f) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Associated Types

type Rep ((a :* b) f) :: Type -> Type #

Methods

from :: (a :* b) f -> Rep ((a :* b) f) x #

to :: Rep ((a :* b) f) x -> (a :* b) f #

(FromJSON (a Maybe), FromJSON (b Maybe), ApplicativeB a, ApplicativeB b, KnownSymbol ta, KnownSymbol tb) => FromJSON ((Tagged ta a :* Tagged tb b) Maybe) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

parseJSON :: Value -> Parser ((Tagged ta a :* Tagged tb b) Maybe) #

parseJSONList :: Value -> Parser [(Tagged ta a :* Tagged tb b) Maybe] #

(FromJSON (a Maybe), FromJSON (b' Maybe), ApplicativeB a, ApplicativeB b', KnownSymbol ta, b' ~ (Tagged tb b :* c)) => FromJSON ((Tagged ta a :* (Tagged tb b :* c)) Maybe) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

parseJSON :: Value -> Parser ((Tagged ta a :* (Tagged tb b :* c)) Maybe) #

parseJSONList :: Value -> Parser [(Tagged ta a :* (Tagged tb b :* c)) Maybe] #

type SourceVal (l :* r) Source # 
Instance details

Defined in Options.Harg.Sources.Types

type SourceVal (l :* r) = (SourceVal l, SourceVal r)
type Rep ((a :* b) f) Source # 
Instance details

Defined in Options.Harg.Het.Prod

type Rep ((a :* b) f) = D1 ('MetaData ":*" "Options.Harg.Het.Prod" "harg-0.5.0.0-inplace" 'False) (C1 ('MetaCons ":*" ('InfixI 'RightAssociative 4) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a f)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (b f))))

newtype Tagged (t :: k) (a :: (Type -> Type) -> Type) (f :: Type -> Type) Source #

This type adds a type-level phantom tag to a higher-kinded type. Its JSON instance allows using :* with JSONSource.

Constructors

Tagged 

Fields

Instances

Instances details
ApplicativeB a => ApplicativeB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bpure :: (forall (a0 :: k). f a0) -> Tagged t a f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Tagged t a f -> Tagged t a g -> Tagged t a (Product f g)

FunctorB a => FunctorB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> Tagged t a f -> Tagged t a g

TraversableB a => TraversableB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> Tagged t a f -> e (Tagged t a g)

(FromJSON (a Maybe), FromJSON (b Maybe), ApplicativeB a, ApplicativeB b, KnownSymbol ta, KnownSymbol tb) => FromJSON ((Tagged ta a :* Tagged tb b) Maybe) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

parseJSON :: Value -> Parser ((Tagged ta a :* Tagged tb b) Maybe) #

parseJSONList :: Value -> Parser [(Tagged ta a :* Tagged tb b) Maybe] #

(FromJSON (a Maybe), FromJSON (b' Maybe), ApplicativeB a, ApplicativeB b', KnownSymbol ta, b' ~ (Tagged tb b :* c)) => FromJSON ((Tagged ta a :* (Tagged tb b :* c)) Maybe) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

parseJSON :: Value -> Parser ((Tagged ta a :* (Tagged tb b :* c)) Maybe) #

parseJSONList :: Value -> Parser [(Tagged ta a :* (Tagged tb b :* c)) Maybe] #

Generic (Tagged t a f) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Associated Types

type Rep (Tagged t a f) :: Type -> Type #

Methods

from :: Tagged t a f -> Rep (Tagged t a f) x #

to :: Rep (Tagged t a f) x -> Tagged t a f #

FromJSON (a f) => FromJSON (Tagged t a f) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

parseJSON :: Value -> Parser (Tagged t a f) #

parseJSONList :: Value -> Parser [Tagged t a f] #

type Rep (Tagged t a f) Source # 
Instance details

Defined in Options.Harg.Het.Prod

type Rep (Tagged t a f) = D1 ('MetaData "Tagged" "Options.Harg.Het.Prod" "harg-0.5.0.0-inplace" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a f))))

Option modifiers

long :: HasLong o attr => String -> o attr a -> o attr a Source #

Add a long modifier to an option

short :: HasShort o attr => Char -> o attr a -> o attr a Source #

Add a short modifier to an option

help :: HasHelp o attr => String -> o attr a -> o attr a Source #

Add help to an option

metavar :: HasMetavar o attr => String -> o attr a -> o attr a Source #

Add a metavar metavar to an option, to be displayed as the meta-parameter next to long/short modifiers

envVar :: HasEnvVar o attr => String -> o attr a -> o attr a Source #

Specify an environment variable to lookup for an option

defaultVal :: (HasDefaultVal o attr, NotInAttrs OptDefault attr (DuplicateAttrMultipleErr "defaultVal" '["defaultStr", "required"]), NotInAttrs OptOptional attr (IncompatibleAttrsErr "defaultVal" "optional")) => a -> o attr a -> o (OptDefault ': attr) a Source #

Add a default value to an option. Cannot be used in conjuction with with required, defaultStr or optional.

defaultStr :: (HasDefaultStr o attr, NotInAttrs OptDefault attr (DuplicateAttrMultipleErr "defaultStr" '["defaultVal", "required"]), NotInAttrs OptOptional attr (IncompatibleAttrsErr "defaultStr" "optional")) => String -> o attr a -> o (OptDefault ': attr) a Source #

Add a default unparsed value to an option. Cannot be used in conjuction with defaultVal, required or optional.

required :: (HasRequired o attr, NotInAttrs OptDefault attr (DuplicateAttrMultipleErr "required" '["defaultVal", "defaultStr"]), NotInAttrs OptOptional attr (IncompatibleAttrsErr "required" "optional")) => o attr a -> o (OptDefault ': attr) a Source #

Mark an option as required. Cannot be used in conjunction with optional, defaultVal or requiredStr.

optional :: (HasOptional o attr, NotInAttrs OptOptional attr (DuplicateAttrErr "optional"), NotInAttrs OptDefault attr (IncompatibleAttrsErr "optional" "defaultVal")) => o attr a -> o (OptOptional ': attr) (Maybe a) Source #

Specify that an option is optional. This will convert an Opt a to an Opt (Maybe a). Cannot be used in conjunction with defaultVal, defaultStr or required.

data Opt a Source #

The basic option type

Instances

Instances details
Functor Opt Source # 
Instance details

Defined in Options.Harg.Types

Methods

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

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

Option parsers

parseWith Source #

Arguments

:: (String -> Maybe a)

Original parser

-> String -> Either String a 

Convert a parser that returns Maybe to a parser that returns Either, with the default Left value unable to parse: <input>.

readParser :: Read a => OptReader a Source #

A parser that uses the Read instance to parse into a type.

strParser :: IsString s => String -> Either String s Source #

A parser that returns a string. Any type that has an instance of IsString will work, and this parser always succeeds.

boolParser :: String -> Either String Bool Source #

A parser that returns a Bool. This will succeed for the strings true and false in a case-insensitive manner.

manyParser Source #

Arguments

:: String

Separator

-> OptReader a

Parser for each string

-> OptReader [a] 

A parser that can parse many items, returning a list.

Executing options

execOpt Source #

Arguments

:: forall c a. (TraversableB a, ApplicativeB a, TraversableB c, ApplicativeB c, GetSource c Identity, RunSource (SourceVal c) a) 
=> c Opt

Source options

-> a Opt

Target configuration options

-> IO (a Identity) 

Run the option parser and combine with values from the specified sources

execOptDef Source #

Arguments

:: forall a. (TraversableB a, ApplicativeB a) 
=> a Opt

Target configuration options

-> IO (a Identity) 

Run the option parser only with default sources (environment variables)

execOptWithCtx Source #

Arguments

:: forall c a. (TraversableB a, ApplicativeB a, TraversableB c, ApplicativeB c, GetSource c Identity, RunSource (SourceVal c) a) 
=> HargCtx

Context containing the environment and the cmdline args

-> c Opt

Source options

-> a Opt

Target configuration options

-> IO (a Identity) 

Run the option parser and combine with values from the specified sources, passing the context explicitly.

execOptWithCtxDef Source #

Arguments

:: forall a. (TraversableB a, ApplicativeB a) 
=> HargCtx

Context containing the environment and the cmdline args

-> a Opt

Target configuration options

-> IO (a Identity) 

Run the option parser only with default sources (environment variables), passing the context explicitly.

execCommands Source #

Arguments

:: forall c ts xs. (TraversableB (VariantF xs), TraversableB c, ApplicativeB c, Subcommands ts xs, GetSource c Identity, All (RunSource (SourceVal (c :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) 
=> c Opt

Source options

-> AssocListF ts xs Opt

Target options associated with subcommands

-> IO (VariantF xs Identity) 

Run the subcommand parser and combine with values from the specified sources

execCommandsDef Source #

Arguments

:: forall ts xs. (TraversableB (VariantF xs), Subcommands ts xs, All (RunSource (SourceVal (DefaultSources :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) 
=> AssocListF ts xs Opt

Target options associated with subcommands

-> IO (VariantF xs Identity) 

Run the subcommand parser only with default sources (environment variables)

execCommandsWithCtx Source #

Arguments

:: forall c ts xs. (TraversableB (VariantF xs), TraversableB c, ApplicativeB c, Subcommands ts xs, GetSource c Identity, All (RunSource (SourceVal (c :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) 
=> HargCtx

Context containing the environment and the cmdline args

-> c Opt

Source options

-> AssocListF ts xs Opt

Target options associated with subcommands

-> IO (VariantF xs Identity) 

Run the subcommand parser and combine with values from the specified sources, passing the context explicitly.

execCommandsWithCtxDef Source #

Arguments

:: forall ts xs. (TraversableB (VariantF xs), Subcommands ts xs, All (RunSource (SourceVal (DefaultSources :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) 
=> HargCtx

Context containing the environment and the cmdline args

-> AssocListF ts xs Opt

Target options associated with subcommands

-> IO (VariantF xs Identity) 

Run the subcommand parser only with default sources (environment variables), passing the context explicitly.

Option sources

data EnvSource (f :: Type -> Type) Source #

Source that enables a parser to read options from environment variables.

Constructors

EnvSource 

Instances

Instances details
GetSource EnvSource f Source # 
Instance details

Defined in Options.Harg.Sources.Env

Associated Types

type SourceVal EnvSource Source #

Generic (EnvSource f) Source # 
Instance details

Defined in Options.Harg.Sources.Env

Associated Types

type Rep (EnvSource f) :: Type -> Type #

Methods

from :: EnvSource f -> Rep (EnvSource f) x #

to :: Rep (EnvSource f) x -> EnvSource f #

ApplicativeB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

bpure :: (forall (a :: k). f a) -> EnvSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). EnvSource f -> EnvSource g -> EnvSource (Product f g)

FunctorB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

bmap :: (forall (a :: k). f a -> g a) -> EnvSource f -> EnvSource g

TraversableB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> EnvSource f -> e (EnvSource g)

type SourceVal EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

type Rep (EnvSource f) Source # 
Instance details

Defined in Options.Harg.Sources.Env

type Rep (EnvSource f) = D1 ('MetaData "EnvSource" "Options.Harg.Sources.Env" "harg-0.5.0.0-inplace" 'False) (C1 ('MetaCons "EnvSource" 'PrefixI 'False) (U1 :: Type -> Type))

newtype JSONSource f Source #

Source that enables a parser to read options from a JSON file.

Constructors

JSONSource (f ConfigFile) 

Instances

Instances details
GetSource JSONSource Identity Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Associated Types

type SourceVal JSONSource Source #

Generic (JSONSource f) Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Associated Types

type Rep (JSONSource f) :: Type -> Type #

Methods

from :: JSONSource f -> Rep (JSONSource f) x #

to :: Rep (JSONSource f) x -> JSONSource f #

ApplicativeB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

bpure :: (forall (a :: k). f a) -> JSONSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). JSONSource f -> JSONSource g -> JSONSource (Product f g)

FunctorB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

bmap :: (forall (a :: k). f a -> g a) -> JSONSource f -> JSONSource g

TraversableB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> JSONSource f -> e (JSONSource g)

type SourceVal JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

type Rep (JSONSource f) Source # 
Instance details

Defined in Options.Harg.Sources.JSON

type Rep (JSONSource f) = D1 ('MetaData "JSONSource" "Options.Harg.Sources.JSON" "harg-0.5.0.0-inplace" 'True) (C1 ('MetaCons "JSONSource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f ConfigFile))))

newtype YAMLSource f Source #

Source that enables a parser to read options from a YAML file.

Constructors

YAMLSource (f ConfigFile) 

Instances

Instances details
GetSource YAMLSource Identity Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Associated Types

type SourceVal YAMLSource Source #

Generic (YAMLSource f) Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Associated Types

type Rep (YAMLSource f) :: Type -> Type #

Methods

from :: YAMLSource f -> Rep (YAMLSource f) x #

to :: Rep (YAMLSource f) x -> YAMLSource f #

ApplicativeB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

bpure :: (forall (a :: k). f a) -> YAMLSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). YAMLSource f -> YAMLSource g -> YAMLSource (Product f g)

FunctorB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

bmap :: (forall (a :: k). f a -> g a) -> YAMLSource f -> YAMLSource g

TraversableB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> YAMLSource f -> e (YAMLSource g)

type SourceVal YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

type Rep (YAMLSource f) Source # 
Instance details

Defined in Options.Harg.Sources.YAML

type Rep (YAMLSource f) = D1 ('MetaData "YAMLSource" "Options.Harg.Sources.YAML" "harg-0.5.0.0-inplace" 'True) (C1 ('MetaCons "YAMLSource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f ConfigFile))))

data ConfigFile Source #

This type describes configuration files, for use with e.g. the JSON source. The reason to not use FilePath directly is that the user might prefer to do nothing if the option for the config file has not been not provided, and there's no default. Because this type has an IsString instance, it's very easy to define an option. For example, to define a json source with a default value:

  srcOpt :: JSONSource Opt
  srcOpt = JSONSource jsonOpt
    where
      jsonOpt
        = optionWith strParser
            ( long "json-config"
            . defaultVal (ConfigFile "~/config.json")
            )

And an optional JSON source:

  srcOpt :: JSONSource Opt
  srcOpt = JSONSource jsonOpt
    where
      jsonOpt
        = optionWith strParser
            ( long "json-config"
            . defaultVal NoConfigFile
            )

Instances

Instances details
IsString ConfigFile Source # 
Instance details

Defined in Options.Harg.Sources.Types

noSources :: NoSource f Source #

Shorthand for writing NoSource.

defaultSources :: DefaultSources f Source #

Default sources, equivalent to EnvSource

Parser context

Variant

data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where Source #

A Variant is similar to nested Eithers. For example, Variant '[Int, Bool, Char] is isomorphic to Either Int (Either Bool Char). VariantF is a variant for higher-kinded types, which means that the type-level list holds types of kind (Type -> Type) -> Type, and the second parameter is the type constructor f :: Type -> Type. To pattern match on a variant, HereF and ThereF can be used:

  getFromVariant :: Variant '[Int, Bool, String] -> Bool
  getFromVariant (ThereF (HereF b)) = b

Constructors

HereF :: x f -> VariantF (x ': xs) f 
ThereF :: VariantF xs f -> VariantF (y ': xs) f 

Instances

Instances details
(FunctorB x, FunctorB (VariantF xs)) => FunctorB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF (x ': xs) f -> VariantF (x ': xs) g

FunctorB (VariantF ('[] :: [(Type -> Type) -> Type])) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF '[] f -> VariantF '[] g

(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF (x ': xs) f -> e (VariantF (x ': xs) g)

TraversableB (VariantF ('[] :: [(Type -> Type) -> Type])) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF '[] f -> e (VariantF '[] g)

fromVariantF :: FromVariantF xs result f => VariantF xs f -> FoldSignatureF xs result f Source #

pattern In1 :: x1 f -> VariantF (x1 ': xs) f Source #

pattern In2 :: x2 f -> VariantF (x1 ': (x2 ': xs)) f Source #

pattern In3 :: x3 f -> VariantF (x1 ': (x2 ': (x3 ': xs))) f Source #

pattern In4 :: x4 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': xs)))) f Source #

pattern In5 :: x5 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': xs))))) f Source #

Re-exports

barbies

class FunctorB (b :: (k -> Type) -> Type) #

Instances

Instances details
(FunctorB x, FunctorB (VariantF xs)) => FunctorB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF (x ': xs) f -> VariantF (x ': xs) g

FunctorB (VariantF ('[] :: [(Type -> Type) -> Type])) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF '[] f -> VariantF '[] g

GFunctorB (Rep structure) => FunctorB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

bmap :: (forall (a :: k). f a -> g a) -> HKD structure f -> HKD structure g

FunctorB (HKD b) => FunctorB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

bmap :: (forall (a :: k). f a -> g a) -> Nested b f -> Nested b g

FunctorB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> Single a f -> Single a g

FunctorB (Void :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Trivial

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Void f -> Void g

FunctorB (Unit :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Trivial

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Unit f -> Unit g

FunctorB (Proxy :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Proxy f -> Proxy g

FunctorB b => FunctorB (Barbie b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Wrappers

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Barbie b f -> Barbie b g

FunctorB (Constant x :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Constant x f -> Constant x g

FunctorB (Const x :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a :: k0). f a -> g a) -> Const x f -> Const x g

FunctorB a => FunctorB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> Tagged t a f -> Tagged t a g

(FunctorB a, FunctorB b) => FunctorB (Sum a b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a0 :: k0). f a0 -> g a0) -> Sum a b f -> Sum a b g

(FunctorB a, FunctorB b) => FunctorB (Product a b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a0 :: k0). f a0 -> g a0) -> Product a b f -> Product a b g

(Functor f, FunctorB b) => FunctorB (Compose f b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.FunctorB

Methods

bmap :: (forall (a :: k0). f0 a -> g a) -> Compose f b f0 -> Compose f b g

FunctorB NoSource Source # 
Instance details

Defined in Options.Harg.Sources.NoSource

Methods

bmap :: (forall (a :: k). f a -> g a) -> NoSource f -> NoSource g

FunctorB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

bmap :: (forall (a :: k). f a -> g a) -> EnvSource f -> EnvSource g

FunctorB DefaultStrSource Source # 
Instance details

Defined in Options.Harg.Sources.DefaultStr

Methods

bmap :: (forall (a :: k). f a -> g a) -> DefaultStrSource f -> DefaultStrSource g

FunctorB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

bmap :: (forall (a :: k). f a -> g a) -> YAMLSource f -> YAMLSource g

FunctorB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

bmap :: (forall (a :: k). f a -> g a) -> JSONSource f -> JSONSource g

(FunctorB a, FunctorB b) => FunctorB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bmap :: (forall (a0 :: k). f a0 -> g a0) -> (a :* b) f -> (a :* b) g

class FunctorB b => TraversableB (b :: (k -> Type) -> Type) #

Instances

Instances details
(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF (x ': xs) f -> e (VariantF (x ': xs) g)

TraversableB (VariantF ('[] :: [(Type -> Type) -> Type])) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF '[] f -> e (VariantF '[] g)

(FunctorB (HKD structure), GTraversableB (Rep structure)) => TraversableB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> HKD structure f -> e (HKD structure g)

TraversableB (HKD b) => TraversableB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> Nested b f -> e (Nested b g)

TraversableB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> Single a f -> e (Single a g)

TraversableB (Void :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Trivial

Methods

btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Void f -> e (Void g)

TraversableB (Unit :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Trivial

Methods

btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Unit f -> e (Unit g)

TraversableB (Proxy :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Proxy f -> e (Proxy g)

TraversableB b => TraversableB (Barbie b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Wrappers

Methods

btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Barbie b f -> e (Barbie b g)

TraversableB (Constant a :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a0 :: k0). f a0 -> e (g a0)) -> Constant a f -> e (Constant a g)

TraversableB (Const a :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a0 :: k0). f a0 -> e (g a0)) -> Const a f -> e (Const a g)

TraversableB a => TraversableB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> Tagged t a f -> e (Tagged t a g)

(TraversableB a, TraversableB b) => TraversableB (Sum a b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a0 :: k0). f a0 -> e (g a0)) -> Sum a b f -> e (Sum a b g)

(TraversableB a, TraversableB b) => TraversableB (Product a b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a0 :: k0). f a0 -> e (g a0)) -> Product a b f -> e (Product a b g)

(Traversable f, TraversableB b) => TraversableB (Compose f b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.TraversableB

Methods

btraverse :: Applicative e => (forall (a :: k0). f0 a -> e (g a)) -> Compose f b f0 -> e (Compose f b g)

TraversableB NoSource Source # 
Instance details

Defined in Options.Harg.Sources.NoSource

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> NoSource f -> e (NoSource g)

TraversableB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> EnvSource f -> e (EnvSource g)

TraversableB DefaultStrSource Source # 
Instance details

Defined in Options.Harg.Sources.DefaultStr

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> DefaultStrSource f -> e (DefaultStrSource g)

TraversableB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> YAMLSource f -> e (YAMLSource g)

TraversableB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> JSONSource f -> e (JSONSource g)

(TraversableB a, TraversableB b) => TraversableB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> (a :* b) f -> e ((a :* b) g)

class FunctorB b => ApplicativeB (b :: (k -> Type) -> Type) #

Instances

Instances details
(FunctorB (HKD structure), GApplicativeB (Rep structure)) => ApplicativeB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

bpure :: (forall (a :: k). f a) -> HKD structure f

bprod :: forall (f :: k -> Type) (g :: k -> Type). HKD structure f -> HKD structure g -> HKD structure (Product f g)

ApplicativeB (HKD b) => ApplicativeB (Nested b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

bpure :: (forall (a :: k). f a) -> Nested b f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Nested b f -> Nested b g -> Nested b (Product f g)

ApplicativeB (Single a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Single

Methods

bpure :: (forall (a0 :: k). f a0) -> Single a f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Single a f -> Single a g -> Single a (Product f g)

ApplicativeB (Unit :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Trivial

Methods

bpure :: (forall (a :: k0). f a) -> Unit f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Unit f -> Unit g -> Unit (Product f g)

ApplicativeB (Proxy :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.ApplicativeB

Methods

bpure :: (forall (a :: k0). f a) -> Proxy f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Proxy f -> Proxy g -> Proxy (Product f g)

ApplicativeB b => ApplicativeB (Barbie b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.Wrappers

Methods

bpure :: (forall (a :: k0). f a) -> Barbie b f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Barbie b f -> Barbie b g -> Barbie b (Product f g)

Monoid a => ApplicativeB (Constant a :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.ApplicativeB

Methods

bpure :: (forall (a0 :: k0). f a0) -> Constant a f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Constant a f -> Constant a g -> Constant a (Product f g)

Monoid a => ApplicativeB (Const a :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.ApplicativeB

Methods

bpure :: (forall (a0 :: k0). f a0) -> Const a f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Const a f -> Const a g -> Const a (Product f g)

ApplicativeB a => ApplicativeB (Tagged t a :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bpure :: (forall (a0 :: k). f a0) -> Tagged t a f

bprod :: forall (f :: k -> Type) (g :: k -> Type). Tagged t a f -> Tagged t a g -> Tagged t a (Product f g)

(ApplicativeB a, ApplicativeB b) => ApplicativeB (Product a b :: (k -> Type) -> Type) 
Instance details

Defined in Barbies.Internal.ApplicativeB

Methods

bpure :: (forall (a0 :: k0). f a0) -> Product a b f

bprod :: forall (f :: k0 -> Type) (g :: k0 -> Type). Product a b f -> Product a b g -> Product a b (Product f g)

ApplicativeB NoSource Source # 
Instance details

Defined in Options.Harg.Sources.NoSource

Methods

bpure :: (forall (a :: k). f a) -> NoSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). NoSource f -> NoSource g -> NoSource (Product f g)

ApplicativeB EnvSource Source # 
Instance details

Defined in Options.Harg.Sources.Env

Methods

bpure :: (forall (a :: k). f a) -> EnvSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). EnvSource f -> EnvSource g -> EnvSource (Product f g)

ApplicativeB DefaultStrSource Source # 
Instance details

Defined in Options.Harg.Sources.DefaultStr

Methods

bpure :: (forall (a :: k). f a) -> DefaultStrSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). DefaultStrSource f -> DefaultStrSource g -> DefaultStrSource (Product f g)

ApplicativeB YAMLSource Source # 
Instance details

Defined in Options.Harg.Sources.YAML

Methods

bpure :: (forall (a :: k). f a) -> YAMLSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). YAMLSource f -> YAMLSource g -> YAMLSource (Product f g)

ApplicativeB JSONSource Source # 
Instance details

Defined in Options.Harg.Sources.JSON

Methods

bpure :: (forall (a :: k). f a) -> JSONSource f

bprod :: forall (f :: k -> Type) (g :: k -> Type). JSONSource f -> JSONSource g -> JSONSource (Product f g)

(ApplicativeB a, ApplicativeB b) => ApplicativeB (a :* b :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Prod

Methods

bpure :: (forall (a0 :: k). f a0) -> (a :* b) f

bprod :: forall (f :: k -> Type) (g :: k -> Type). (a :* b) f -> (a :* b) g -> (a :* b) (Product f g)

newtype Rec p a (x :: k) #

Constructors

Rec 

Fields

Instances

Instances details
GTraversable (n :: Nat) (f :: k1 -> Type) (g :: k1 -> Type) (Rec (P n f a') (f a) :: k2 -> Type) (Rec (P n g a') (g a) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Traversable

Methods

gtraverse :: forall t (x :: k20). Applicative t => Proxy n -> (forall (a0 :: k10). f a0 -> t (g a0)) -> Rec (P n f a') (f a) x -> t (Rec (P n g a') (g a) x)

Traversable h => GTraversable (n :: Nat) (f :: k1 -> Type) (g :: k1 -> Type) (Rec (h (P n f a)) (h (f a)) :: k2 -> Type) (Rec (h (P n g a)) (h (g a)) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Traversable

Methods

gtraverse :: forall t (x :: k20). Applicative t => Proxy n -> (forall (a0 :: k10). f a0 -> t (g a0)) -> Rec (h (P n f a)) (h (f a)) x -> t (Rec (h (P n g a)) (h (g a)) x)

GTraversable (n :: k1) (f :: k2 -> Type) (g :: k2 -> Type) (Rec a a :: k3 -> Type) (Rec a a :: k3 -> Type) 
Instance details

Defined in Barbies.Generics.Traversable

Methods

gtraverse :: forall t (x :: k20). Applicative t => Proxy n -> (forall (a0 :: k10). f a0 -> t (g a0)) -> Rec a a x -> t (Rec a a x)

GConstraints n (c :: k1 -> Constraint) (f :: k2) (Rec a' a :: Type -> Type) (Rec b' b :: k3 -> Type) (Rec b' b :: k3 -> Type) 
Instance details

Defined in Barbies.Generics.Constraints

Methods

gaddDicts :: forall (x :: k20). GAll n c (Rec a' a) => Rec b' b x -> Rec b' b x

GApplicative (n :: Nat) (f :: k1 -> Type) (g :: k1 -> Type) (Rec (P n f a) (f a) :: k2 -> Type) (Rec (P n g a) (g a) :: k2 -> Type) (Rec (P n (Product f g) a) (Product f g a) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Applicative

Methods

gprod :: forall (x :: k10). Proxy n -> Proxy f -> Proxy g -> Rec (P n f a) (f a) x -> Rec (P n g a) (g a) x -> Rec (P n (Product f g) a) (Product f g a) x

gpure :: forall (x :: k10). (f ~ g, Rec (P n f a) (f a) ~ Rec (P n g a) (g a)) => Proxy n -> Proxy f -> Proxy (Rec (P n f a) (f a)) -> Proxy (Rec (P n (Product f g) a) (Product f g a)) -> (forall (a0 :: k20). f a0) -> Rec (P n f a) (f a) x

Applicative h => GApplicative (n :: Nat) (f :: k1 -> Type) (g :: k1 -> Type) (Rec (h (P n f a)) (h (f a)) :: k2 -> Type) (Rec (h (P n g a)) (h (g a)) :: k2 -> Type) (Rec (h (P n (Product f g) a)) (h (Product f g a)) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Applicative

Methods

gprod :: forall (x :: k10). Proxy n -> Proxy f -> Proxy g -> Rec (h (P n f a)) (h (f a)) x -> Rec (h (P n g a)) (h (g a)) x -> Rec (h (P n (Product f g) a)) (h (Product f g a)) x

gpure :: forall (x :: k10). (f ~ g, Rec (h (P n f a)) (h (f a)) ~ Rec (h (P n g a)) (h (g a))) => Proxy n -> Proxy f -> Proxy (Rec (h (P n f a)) (h (f a))) -> Proxy (Rec (h (P n (Product f g) a)) (h (Product f g a))) -> (forall (a0 :: k20). f a0) -> Rec (h (P n f a)) (h (f a)) x

Monoid x => GApplicative (n :: k1) (f :: k2 -> Type) (g :: k2 -> Type) (Rec x x :: k3 -> Type) (Rec x x :: k3 -> Type) (Rec x x :: k3 -> Type) 
Instance details

Defined in Barbies.Generics.Applicative

Methods

gprod :: forall (x0 :: k10). Proxy n -> Proxy f -> Proxy g -> Rec x x x0 -> Rec x x x0 -> Rec x x x0

gpure :: forall (x0 :: k10). (f ~ g, Rec x x ~ Rec x x) => Proxy n -> Proxy f -> Proxy (Rec x x) -> Proxy (Rec x x) -> (forall (a :: k20). f a) -> Rec x x x0

GFunctor n (f :: k1 -> Type) (g :: k1 -> Type) (Rec (P n f a') (f a) :: k2 -> Type) (Rec (P n g a') (g a) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Functor

Methods

gmap :: forall (x :: k10). Proxy n -> (forall (a0 :: k). f a0 -> g a0) -> Rec (P n f a') (f a) x -> Rec (P n g a') (g a) x

Functor h => GFunctor n (f :: k1 -> Type) (g :: k1 -> Type) (Rec (h (P n f a')) (h (f a)) :: k2 -> Type) (Rec (h (P n g a')) (h (g a)) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Functor

Methods

gmap :: forall (x :: k10). Proxy n -> (forall (a0 :: k). f a0 -> g a0) -> Rec (h (P n f a')) (h (f a)) x -> Rec (h (P n g a')) (h (g a)) x

GFunctor n (f :: k1 -> Type) (g :: k1 -> Type) (Rec x x :: k2 -> Type) (Rec x x :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Functor

Methods

gmap :: forall (x0 :: k10). Proxy n -> (forall (a :: k). f a -> g a) -> Rec x x x0 -> Rec x x x0

GConstraints n (c :: k1 -> Constraint) (f :: k1 -> Type) (Rec (P n (X :: k1 -> Type) a') (X a) :: Type -> Type) (Rec (P n f a') (f a) :: k2 -> Type) (Rec (P n (Product (Dict c) f) a') (Product (Dict c) f a) :: k2 -> Type) 
Instance details

Defined in Barbies.Generics.Constraints

Methods

gaddDicts :: forall (x :: k20). GAll n c (Rec (P n X a') (X a)) => Rec (P n f a') (f a) x -> Rec (P n (Product (Dict c) f) a') (Product (Dict c) f a) x

type GAll n (c :: k -> Constraint) (Rec l r :: Type -> Type) 
Instance details

Defined in Barbies.Generics.Constraints

type GAll n (c :: k -> Constraint) (Rec l r :: Type -> Type) = GAllRec n c l r

higgledy

data HKD structure (f :: Type -> Type) #

Instances

Instances details
GBuild f structure ('[] :: [Type]) (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Build

Methods

gbuild :: (HList '[] -> HKD structure f) -> HKD structure f

(FunctorB (HKD structure), GApplicativeB (Rep structure)) => ApplicativeB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

bpure :: (forall (a :: k). f a) -> HKD structure f

bprod :: forall (f :: k -> Type) (g :: k -> Type). HKD structure f -> HKD structure g -> HKD structure (Product f g)

(FunctorB (HKD structure), GConstraintsB (Rep structure), GAllBC (Rep structure)) => ConstraintsB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Associated Types

type AllB c (HKD structure)

Methods

baddDicts :: forall (c :: k -> Constraint) (f :: k -> Type). AllB c (HKD structure) => HKD structure f -> HKD structure (Product (Dict c) f)

GFunctorB (Rep structure) => FunctorB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

bmap :: (forall (a :: k). f a -> g a) -> HKD structure f -> HKD structure g

(FunctorB (HKD structure), GTraversableB (Rep structure)) => TraversableB (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> HKD structure f -> e (HKD structure g)

(Eq tuple, Generic xs, Tuple f xs tuple) => Eq (HKD xs f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

(==) :: HKD xs f -> HKD xs f -> Bool #

(/=) :: HKD xs f -> HKD xs f -> Bool #

(Ord tuple, Generic xs, Tuple f xs tuple) => Ord (HKD xs f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

compare :: HKD xs f -> HKD xs f -> Ordering #

(<) :: HKD xs f -> HKD xs f -> Bool #

(<=) :: HKD xs f -> HKD xs f -> Bool #

(>) :: HKD xs f -> HKD xs f -> Bool #

(>=) :: HKD xs f -> HKD xs f -> Bool #

max :: HKD xs f -> HKD xs f -> HKD xs f #

min :: HKD xs f -> HKD xs f -> HKD xs f #

(Generic structure, GShow 'True (HKD_ f structure)) => Show (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

showsPrec :: Int -> HKD structure f -> ShowS #

show :: HKD structure f -> String #

showList :: [HKD structure f] -> ShowS #

(Contravariant (HKD_ f structure), Functor (HKD_ f structure)) => Generic (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

Associated Types

type Rep (HKD structure f) :: Type -> Type #

Methods

from :: HKD structure f -> Rep (HKD structure f) x #

to :: Rep (HKD structure f) x -> HKD structure f #

(Semigroup tuple, Generic xs, Tuple f xs tuple) => Semigroup (HKD xs f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

(<>) :: HKD xs f -> HKD xs f -> HKD xs f #

sconcat :: NonEmpty (HKD xs f) -> HKD xs f #

stimes :: Integral b => b -> HKD xs f -> HKD xs f #

(Monoid tuple, Generic xs, Tuple f xs tuple) => Monoid (HKD xs f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

mempty :: HKD xs f #

mappend :: HKD xs f -> HKD xs f -> HKD xs f #

mconcat :: [HKD xs f] -> HKD xs f #

(Generic structure, Function tuple, Tuple f structure tuple) => Function (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

function :: (HKD structure f -> b) -> HKD structure f :-> b #

(Arbitrary tuple, GToTuple (HKD_ f structure) tuple) => Arbitrary (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

arbitrary :: Gen (HKD structure f) #

shrink :: HKD structure f -> [HKD structure f] #

(CoArbitrary tuple, GToTuple (HKD_ f structure) tuple) => CoArbitrary (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

Methods

coarbitrary :: HKD structure f -> Gen b -> Gen b #

GFromJSON Zero (HKD_ f structure) => FromJSON (HKD structure f) Source # 
Instance details

Defined in Options.Harg.Nested

Methods

parseJSON :: Value -> Parser (HKD structure f) #

parseJSONList :: Value -> Parser [HKD structure f] #

type AllB (c :: Type -> Constraint) (HKD structure :: (Type -> Type) -> Type) 
Instance details

Defined in Data.Generic.HKD.Types

type AllB (c :: Type -> Constraint) (HKD structure :: (Type -> Type) -> Type) = GAllB c (Rep structure)
type Rep (HKD structure f) 
Instance details

Defined in Data.Generic.HKD.Types

type Rep (HKD structure f) = HKD_ f structure

class Build structure (f :: Type -> Type) k | f structure -> k #

Minimal complete definition

build

Instances

Instances details
(Fill f structure xs, GBuild f structure xs k) => Build structure f k 
Instance details

Defined in Data.Generic.HKD.Build

Methods

build :: k #

build :: Build structure f k => k #

class Construct (f :: Type -> Type) structure #

Minimal complete definition

construct, deconstruct

Instances

Instances details
(Applicative f, Generic structure, GConstruct f (Rep structure)) => Construct f structure 
Instance details

Defined in Data.Generic.HKD.Construction

Methods

construct :: HKD structure f -> f structure #

deconstruct :: structure -> HKD structure f

construct :: Construct f structure => HKD structure f -> f structure #