Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class GenericTraverse f where
- type GenericTraverseC f a :: Constraint
- genericTraverseAction :: GenericTraverseC f a => String -> String -> Maybe String -> Natural -> f a
- genericTraverseNonSum :: forall f a. (Generic a, GTraverseNonSum f (Rep a), Functor f) => f a
- class GTraverseNonSum f f'
- class (GenericTraverse f, Alternative f, Monad f) => GenericTraverseSum f where
- genericTraverseSumPfxTagAction :: GenericTraverseC f pt => String -> f pt
- genericTraverseSumNoMatchingCstrAction :: String -> [String] -> Text -> f a
- data PfxTagCfg a = PfxTagCfg {
- pfxTagCfgFromCstr :: String -> a
- pfxTagCfgEq :: a -> a -> Bool
- pfxTagCfgShow :: a -> Text
- genericTraverseSum :: forall f a pt. (Generic a, GTraverseSum f (Rep a), GenericTraverseC f pt, Functor f) => PfxTagCfg pt -> f a
- class GTraverseSum f f'
- eqShowPfxTagCfg :: (Eq a, Show a) => (String -> a) -> PfxTagCfg a
Documentation
class GenericTraverse f where Source #
Applicative
functors that can be generically traverse
d.
type GenericTraverseC f a :: Constraint Source #
The type class providing (applicative) actions for permitted types.
genericTraverseAction Source #
:: GenericTraverseC f a | |
=> String | data type name |
-> String | constructor name |
-> Maybe String | record name (if present) |
-> Natural | field index |
-> f 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.)
Instances
GenericTraverse EmptyRec0 Source # |
Can result in type errors lacking context: a field missing a Maybe silly. |
Defined in Generic.Data.Function.Traverse.Constructor type GenericTraverseC EmptyRec0 a Source # | |
GenericTraverse NoRec0 Source # |
|
Defined in Generic.Data.Function.Traverse.Constructor type GenericTraverseC NoRec0 a Source # |
genericTraverseNonSum :: forall f a. (Generic a, GTraverseNonSum f (Rep a), Functor f) => f a Source #
Generic traverse
over a term of non-sum data type f a
.
f a
must have exactly one constructor.
class GTraverseNonSum f f' Source #
Instances
(Functor f, GTraverseNonSum' cd f f') => GTraverseNonSum (f :: Type -> Type) (D1 cd f' :: k -> Type) Source # | |
Defined in Generic.Data.Function.Traverse.NonSum gTraverseNonSum :: forall (p :: k0). f (D1 cd f' p) Source # |
class (GenericTraverse f, Alternative f, Monad f) => GenericTraverseSum f where Source #
Sum-type monads that can be generically traverse
d.
For sum types, we require a monad with choice to differentiate constructors.
genericTraverseSumPfxTagAction Source #
:: GenericTraverseC f pt | |
=> String | data type name |
-> f pt |
Try to parse a prefix tag of type pt
.
Relevant metadata is provided as arguments.
genericTraverseSumNoMatchingCstrAction Source #
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 f a pt. (Generic a, GTraverseSum f (Rep a), GenericTraverseC f pt, Functor f) => PfxTagCfg pt -> f a Source #
Generic traverse
over a term of sum data type f a
.
f a
must have at least two constructors.
You must provide a configuration for how to handle constructors.
class GTraverseSum f f' Source #
Instances
(Functor f, GTraverseSum' cd f f') => GTraverseSum f (D1 cd f' :: k -> Type) Source # | |
Defined in Generic.Data.Function.Traverse.Sum gTraverseSum :: forall pt (p :: k0). GenericTraverseC f pt => PfxTagCfg pt -> f (D1 cd f' p) Source # |