Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class GenericTraverse tag where
- type GenericTraverseF tag :: Type -> Type
- type GenericTraverseC tag a :: Constraint
- genericTraverseAction :: GenericTraverseC tag a => String -> String -> Maybe String -> Natural -> GenericTraverseF tag a
- genericTraverseV1 :: GenericTraverseF tag (V1 p)
- genericTraverseNonSum :: forall {k} (tag :: k) a. (Generic a, Functor (GenericTraverseF tag), GTraverseNonSum tag (Rep a)) => GenericTraverseF tag a
- class GTraverseNonSum tag gf
- class GenericTraverse tag => GenericTraverseSum tag where
- genericTraverseSumPfxTagAction :: GenericTraverseC tag pt => String -> GenericTraverseF tag pt
- genericTraverseSumNoMatchingCstrAction :: String -> [String] -> Text -> GenericTraverseF tag a
- data PfxTagCfg a = PfxTagCfg {
- pfxTagCfgFromCstr :: String -> a
- pfxTagCfgEq :: a -> a -> Bool
- pfxTagCfgShow :: a -> Text
- genericTraverseSum :: forall {k} (tag :: k) a pt. (Generic a, Functor (GenericTraverseF tag), GTraverseSum tag (Rep a), GenericTraverseC tag pt) => PfxTagCfg pt -> GenericTraverseF tag a
- class GTraverseSum tag gf
- eqShowPfxTagCfg :: (Eq a, Show a) => (String -> a) -> PfxTagCfg a
Documentation
class GenericTraverse tag where Source #
Implementation enumeration type class for generic traverse
.
The type variable is uninstantiated, used purely as a tag. Good types include the type class used inside (providing you define the type class/it's not an orphan instance), or a custom void data type. See the binrep library on Hackage for an example.
type GenericTraverseF tag :: Type -> Type Source #
The target Applicative
to traverse
to.
type GenericTraverseC tag a :: Constraint Source #
The type class providing the action in traverse
for permitted types.
genericTraverseAction Source #
:: GenericTraverseC tag a | |
=> String | data type name |
-> String | constructor name |
-> Maybe String | record name (if present) |
-> Natural | field index |
-> GenericTraverseF tag a |
The action in traverse
(first argument).
We include data type metadata because this function is useful for monadic parsers, which can record it in error messages. (We don't do it for foldMap because it's pure.)
genericTraverseV1 :: GenericTraverseF tag (V1 p) Source #
Instances
genericTraverseNonSum :: forall {k} (tag :: k) a. (Generic a, Functor (GenericTraverseF tag), GTraverseNonSum tag (Rep a)) => GenericTraverseF tag a Source #
Generic traverse
over a term of non-sum data type f a
,
where f
is set by the tag
you pass.
class GTraverseNonSum tag gf Source #
Instances
(Functor (GenericTraverseF tag), GTraverseNonSumD tag cd gf) => GTraverseNonSum (tag :: k1) (D1 cd gf :: k2 -> Type) Source # | |
Defined in Generic.Data.Function.Traverse.NonSum gTraverseNonSum :: forall (p :: k10). GenericTraverseF tag (D1 cd gf p) Source # |
class GenericTraverse tag => GenericTraverseSum tag where Source #
Sum type monads that can be generically traverse
d.
genericTraverseSumPfxTagAction Source #
:: GenericTraverseC tag pt | |
=> String | data type name |
-> GenericTraverseF tag pt |
Try to parse a prefix tag of type pt
.
Relevant metadata is provided as arguments.
genericTraverseSumNoMatchingCstrAction Source #
:: String | data type name |
-> [String] | non-matching constructor names |
-> Text | prefix tag, prettified |
-> GenericTraverseF tag a |
Parse error due to no constructor matching the parsed prefix tag.
Relevant metadata is provided as arguments.
How to use a type as a prefix tag in a generic sum type parser.
PfxTagCfg | |
|
genericTraverseSum :: forall {k} (tag :: k) a pt. (Generic a, Functor (GenericTraverseF tag), GTraverseSum tag (Rep a), GenericTraverseC tag pt) => PfxTagCfg pt -> GenericTraverseF tag a Source #
Generic traverse
over a term of sum data type f a
,
where f
is set by the tag
you pass.
You must provide a configuration for how to handle constructors.
class GTraverseSum tag gf Source #
Instances
GenericTraverse tag => GTraverseSum (tag :: k1) (V1 :: k2 -> Type) Source # | |
Defined in Generic.Data.Function.Traverse.Sum gTraverseSum :: forall pt (p :: k10). GenericTraverseC tag pt => PfxTagCfg pt -> GenericTraverseF tag (V1 p) Source # | |
(Alternative (GenericTraverseF tag), Monad (GenericTraverseF tag), GenericTraverseSum tag, GTraverseCSum tag cd gf, Datatype cd, KnownSymbols (CstrNames gf)) => GTraverseSum (tag :: k1) (D1 cd gf :: k2 -> Type) Source # | Test all constructors of the given non-void data type; if they all fail, run a failure action and pass it all the constructors names in the type. |
Defined in Generic.Data.Function.Traverse.Sum gTraverseSum :: forall pt (p :: k10). GenericTraverseC tag pt => PfxTagCfg pt -> GenericTraverseF tag (D1 cd gf p) Source # |