Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- option :: OptReader a -> (OptionOpt '[] a -> OptionOpt attr b) -> Opt b
- flag :: a -> a -> (FlagOpt '[] a -> FlagOpt attr b) -> Opt b
- switch :: (FlagOpt '[] Bool -> FlagOpt attr Bool) -> Opt Bool
- switch' :: (FlagOpt '[] Bool -> FlagOpt attr Bool) -> Opt Bool
- argument :: OptReader a -> (ArgumentOpt '[] a -> ArgumentOpt attr b) -> Opt b
- newtype Single (a :: Type) (f :: Type -> Type) = Single {
- getSingle :: f a
- single :: f a -> Single a f
- fromSingle :: Single a Identity -> a
- newtype Nested (b :: Type) (f :: Type -> Type) = Nested (HKD b f)
- getNested :: Construct f b => Nested b f -> f b
- nested :: forall b f k. (Build b f k, Coercible (HKD b f) (Nested b f), Coercible k (Nest k f)) => Nest k f
- fromNested :: Construct Identity b => Nested b Identity -> b
- data AssocListF (ts :: [Symbol]) (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where
- 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 ...
- pattern (:+) :: x f -> AssocListF ts xs f -> AssocListF (t ': ts) (x ': xs) f
- data (t :: Symbol) :-> (v :: (Type -> Type) -> Type) :: (Type -> Type) -> Type
- data ((a :: (Type -> Type) -> Type) :* (b :: (Type -> Type) -> Type)) (f :: Type -> Type) = (a f) :* (b f)
- newtype Tagged (t :: k) (a :: (Type -> Type) -> Type) (f :: Type -> Type) = Tagged {
- unTagged :: a f
- long :: HasLong o attr => String -> o attr a -> o attr a
- short :: HasShort o attr => Char -> o attr a -> o attr a
- help :: HasHelp o attr => String -> o attr a -> o attr a
- metavar :: HasMetavar o attr => String -> o attr a -> o attr a
- envVar :: HasEnvVar o attr => String -> o attr a -> o attr a
- 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
- 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
- required :: (HasRequired o attr, NotInAttrs OptDefault attr (DuplicateAttrMultipleErr "required" '["defaultVal", "defaultStr"]), NotInAttrs OptOptional attr (IncompatibleAttrsErr "required" "optional")) => o attr a -> o (OptDefault ': attr) a
- optional :: (HasOptional o attr, NotInAttrs OptOptional attr (DuplicateAttrErr "optional"), NotInAttrs OptDefault attr (IncompatibleAttrsErr "optional" "defaultVal")) => o attr a -> o (OptOptional ': attr) (Maybe a)
- data Opt a
- parseWith :: (String -> Maybe a) -> String -> Either String a
- readParser :: Read a => OptReader a
- strParser :: IsString s => String -> Either String s
- boolParser :: String -> Either String Bool
- manyParser :: String -> OptReader a -> OptReader [a]
- execOpt :: forall c a. (TraversableB a, ApplicativeB a, TraversableB c, ApplicativeB c, GetSource c Identity, RunSource (SourceVal c) a) => c Opt -> a Opt -> IO (a Identity)
- execOptDef :: forall a. (TraversableB a, ApplicativeB a) => a Opt -> IO (a Identity)
- execOptWithCtx :: forall c a. (TraversableB a, ApplicativeB a, TraversableB c, ApplicativeB c, GetSource c Identity, RunSource (SourceVal c) a) => HargCtx -> c Opt -> a Opt -> IO (a Identity)
- execOptWithCtxDef :: forall a. (TraversableB a, ApplicativeB a) => HargCtx -> a Opt -> IO (a Identity)
- execCommands :: 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 -> AssocListF ts xs Opt -> IO (VariantF xs Identity)
- execCommandsDef :: forall ts xs. (TraversableB (VariantF xs), Subcommands ts xs, All (RunSource (SourceVal (DefaultSources :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) => AssocListF ts xs Opt -> IO (VariantF xs Identity)
- execCommandsWithCtx :: 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 -> c Opt -> AssocListF ts xs Opt -> IO (VariantF xs Identity)
- execCommandsWithCtxDef :: forall ts xs. (TraversableB (VariantF xs), Subcommands ts xs, All (RunSource (SourceVal (DefaultSources :* HiddenSources))) xs, All (RunSource ()) xs, MapAssocList xs) => HargCtx -> AssocListF ts xs Opt -> IO (VariantF xs Identity)
- data EnvSource (f :: Type -> Type) = EnvSource
- newtype JSONSource f = JSONSource (f ConfigFile)
- newtype YAMLSource f = YAMLSource (f ConfigFile)
- data ConfigFile
- noSources :: NoSource f
- defaultSources :: DefaultSources f
- getCtx :: IO HargCtx
- ctxFromArgs :: Args -> IO HargCtx
- ctxFromEnv :: Environment -> IO HargCtx
- pureCtx :: Environment -> Args -> HargCtx
- data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where
- fromVariantF :: FromVariantF xs result f => VariantF xs f -> FoldSignatureF xs result f
- pattern In1 :: x1 f -> VariantF (x1 ': xs) f
- pattern In2 :: x2 f -> VariantF (x1 ': (x2 ': xs)) f
- pattern In3 :: x3 f -> VariantF (x1 ': (x2 ': (x3 ': xs))) f
- pattern In4 :: x4 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': xs)))) f
- pattern In5 :: x5 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': xs))))) f
- class FunctorB (b :: (k -> Type) -> Type)
- class FunctorB b => TraversableB (b :: (k -> Type) -> Type)
- class FunctorB b => ApplicativeB (b :: (k -> Type) -> Type)
- newtype Rec p a (x :: k) = Rec {}
- data HKD structure (f :: Type -> Type)
- class Build structure (f :: Type -> Type) k | f structure -> k
- build :: Build structure f k => k
- class Construct (f :: Type -> Type) structure
- construct :: Construct f structure => HKD structure f -> f structure
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
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" )
argument :: OptReader a -> (ArgumentOpt '[] a -> ArgumentOpt attr b) -> Opt b Source #
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 ...
Instances
ApplicativeB (Single a :: (Type -> Type) -> Type) Source # | |
FunctorB (Single a :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Single | |
TraversableB (Single a :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Single 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 # | |
Generic (f a) => Generic (Single a f) Source # | |
FromJSON (f a) => FromJSON (Single a f) Source # | |
type Rep (Single a f) Source # | |
Defined in Options.Harg.Single |
fromSingle :: Single a Identity -> a Source #
Helper for when f ~ Identity
newtype Nested (b :: Type) (f :: Type -> Type) Source #
Newtype wrapper around HKD
.
Instances
ApplicativeB (HKD b) => ApplicativeB (Nested b :: (Type -> Type) -> Type) Source # | |
FunctorB (HKD b) => FunctorB (Nested b :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Nested | |
TraversableB (HKD b) => TraversableB (Nested b :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Nested 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 # | |
FromJSON (HKD b f) => FromJSON (Nested b f) Source # | |
type Rep (Nested b f) Source # | |
Defined in Options.Harg.Nested |
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 #
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 Symbol
s that act
as tags for each type.
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.
(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 ((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 = ...
(a f) :* (b f) infixr 4 |
Instances
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
.
Instances
ApplicativeB a => ApplicativeB (Tagged t a :: (Type -> Type) -> Type) Source # | |
FunctorB a => FunctorB (Tagged t a :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Prod | |
TraversableB a => TraversableB (Tagged t a :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Prod 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 # | |
(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 # | |
Generic (Tagged t a f) Source # | |
FromJSON (a f) => FromJSON (Tagged t a f) Source # | |
type Rep (Tagged t a f) Source # | |
Defined in Options.Harg.Het.Prod |
Option modifiers
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
.
The basic option type
Option parsers
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.
A parser that can parse many items, returning a list.
Executing options
:: 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
:: forall a. (TraversableB a, ApplicativeB a) | |
=> a Opt | Target configuration options |
-> IO (a Identity) |
Run the option parser only with default sources (environment variables)
:: 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.
:: 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.
:: 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
:: 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)
:: 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 #
:: 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.
Instances
GetSource EnvSource f Source # | |
Generic (EnvSource f) Source # | |
ApplicativeB EnvSource Source # | |
FunctorB EnvSource Source # | |
Defined in Options.Harg.Sources.Env | |
TraversableB EnvSource Source # | |
Defined in Options.Harg.Sources.Env btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> EnvSource f -> e (EnvSource g) | |
type SourceVal EnvSource Source # | |
Defined in Options.Harg.Sources.Env | |
type Rep (EnvSource f) Source # | |
newtype JSONSource f Source #
Source that enables a parser to read options from a JSON file.
JSONSource (f ConfigFile) |
Instances
newtype YAMLSource f Source #
Source that enables a parser to read options from a YAML file.
YAMLSource (f ConfigFile) |
Instances
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
IsString ConfigFile Source # | |
Defined in Options.Harg.Sources.Types fromString :: String -> ConfigFile # |
defaultSources :: DefaultSources f Source #
Default sources, equivalent to EnvSource
Parser context
ctxFromArgs :: Args -> IO HargCtx Source #
ctxFromEnv :: Environment -> IO HargCtx Source #
pureCtx :: Environment -> Args -> HargCtx Source #
Variant
data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where Source #
A Variant is similar to nested Either
s. 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
Instances
(FunctorB x, FunctorB (VariantF xs)) => FunctorB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Variant | |
FunctorB (VariantF ('[] :: [(Type -> Type) -> Type])) Source # | |
Defined in Options.Harg.Het.Variant | |
(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Variant 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 # | |
Defined in Options.Harg.Het.Variant 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 #
Re-exports
barbies
class FunctorB (b :: (k -> Type) -> Type) #
Instances
class FunctorB b => TraversableB (b :: (k -> Type) -> Type) #
Instances
(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Variant 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 # | |
Defined in Options.Harg.Het.Variant 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) | |
Defined in Data.Generic.HKD.Types 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 # | |
Defined in Options.Harg.Nested 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 # | |
Defined in Options.Harg.Single btraverse :: Applicative e => (forall (a0 :: k). f a0 -> e (g a0)) -> Single a f -> e (Single a g) | |
TraversableB (Void :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.Trivial btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Void f -> e (Void g) | |
TraversableB (Unit :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.Trivial btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Unit f -> e (Unit g) | |
TraversableB (Proxy :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.TraversableB btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Proxy f -> e (Proxy g) | |
TraversableB b => TraversableB (Barbie b :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.Wrappers btraverse :: Applicative e => (forall (a :: k0). f a -> e (g a)) -> Barbie b f -> e (Barbie b g) | |
TraversableB (Constant a :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.TraversableB btraverse :: Applicative e => (forall (a0 :: k0). f a0 -> e (g a0)) -> Constant a f -> e (Constant a g) | |
TraversableB (Const a :: (k -> Type) -> Type) | |
Defined in Barbies.Internal.TraversableB 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 # | |
Defined in Options.Harg.Het.Prod 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) | |
Defined in Barbies.Internal.TraversableB 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) | |
Defined in Barbies.Internal.TraversableB 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) | |
Defined in Barbies.Internal.TraversableB btraverse :: Applicative e => (forall (a :: k0). f0 a -> e (g a)) -> Compose f b f0 -> e (Compose f b g) | |
TraversableB NoSource Source # | |
Defined in Options.Harg.Sources.NoSource btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> NoSource f -> e (NoSource g) | |
TraversableB EnvSource Source # | |
Defined in Options.Harg.Sources.Env btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> EnvSource f -> e (EnvSource g) | |
TraversableB DefaultStrSource Source # | |
Defined in Options.Harg.Sources.DefaultStr btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> DefaultStrSource f -> e (DefaultStrSource g) | |
TraversableB YAMLSource Source # | |
Defined in Options.Harg.Sources.YAML btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> YAMLSource f -> e (YAMLSource g) | |
TraversableB JSONSource Source # | |
Defined in Options.Harg.Sources.JSON 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 # | |
Defined in Options.Harg.Het.Prod 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
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) | |
Defined in Barbies.Generics.Traversable 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) | |
Defined in Barbies.Generics.Traversable 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) | |
Defined in Barbies.Generics.Traversable 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) | |
Defined in Barbies.Generics.Constraints | |
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) | |
Defined in Barbies.Generics.Applicative 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) | |
Defined in Barbies.Generics.Applicative 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) | |
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) | |
Defined in Barbies.Generics.Functor | |
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) | |
Defined in Barbies.Generics.Functor | |
GFunctor n (f :: k1 -> Type) (g :: k1 -> Type) (Rec x x :: k2 -> Type) (Rec x x :: k2 -> Type) | |
Defined in Barbies.Generics.Functor | |
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) | |
type GAll n (c :: k -> Constraint) (Rec l r :: Type -> Type) | |
Defined in Barbies.Generics.Constraints |
higgledy
data HKD structure (f :: Type -> Type) #
Instances
GBuild f structure ('[] :: [Type]) (HKD structure f) | |
Defined in Data.Generic.HKD.Build | |
(FunctorB (HKD structure), GApplicativeB (Rep structure)) => ApplicativeB (HKD structure :: (Type -> Type) -> Type) | |
(FunctorB (HKD structure), GConstraintsB (Rep structure), GAllBC (Rep structure)) => ConstraintsB (HKD structure :: (Type -> Type) -> Type) | |
Defined in Data.Generic.HKD.Types type AllB c (HKD structure) | |
GFunctorB (Rep structure) => FunctorB (HKD structure :: (Type -> Type) -> Type) | |
Defined in Data.Generic.HKD.Types | |
(FunctorB (HKD structure), GTraversableB (Rep structure)) => TraversableB (HKD structure :: (Type -> Type) -> Type) | |
Defined in Data.Generic.HKD.Types 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) | |
(Ord tuple, Generic xs, Tuple f xs tuple) => Ord (HKD xs f) | |
Defined in Data.Generic.HKD.Types | |
(Generic structure, GShow 'True (HKD_ f structure)) => Show (HKD structure f) | |
(Contravariant (HKD_ f structure), Functor (HKD_ f structure)) => Generic (HKD structure f) | |
(Semigroup tuple, Generic xs, Tuple f xs tuple) => Semigroup (HKD xs f) | |
(Monoid tuple, Generic xs, Tuple f xs tuple) => Monoid (HKD xs f) | |
(Generic structure, Function tuple, Tuple f structure tuple) => Function (HKD structure f) | |
(Arbitrary tuple, GToTuple (HKD_ f structure) tuple) => Arbitrary (HKD structure f) | |
(CoArbitrary tuple, GToTuple (HKD_ f structure) tuple) => CoArbitrary (HKD structure f) | |
Defined in Data.Generic.HKD.Types coarbitrary :: HKD structure f -> Gen b -> Gen b # | |
GFromJSON Zero (HKD_ f structure) => FromJSON (HKD structure f) Source # | |
type AllB (c :: Type -> Constraint) (HKD structure :: (Type -> Type) -> Type) | |
Defined in Data.Generic.HKD.Types | |
type Rep (HKD structure f) | |
Defined in Data.Generic.HKD.Types |
class Build structure (f :: Type -> Type) k | f structure -> k #
Instances
(Fill f structure xs, GBuild f structure xs k) => Build structure f k | |
Defined in Data.Generic.HKD.Build |
class Construct (f :: Type -> Type) structure #
construct, deconstruct
Instances
(Applicative f, Generic structure, GConstruct f (Rep structure)) => Construct f structure | |
Defined in Data.Generic.HKD.Construction construct :: HKD structure f -> f structure # deconstruct :: structure -> HKD structure f |