Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
foldMap
for sum types, where constructors are encoded by index
(distance from first/leftmost constructor) in a single byte, which is
prepended to their contents.
TODO. Clumsy and limited. And yet, still handy enough I think.
Synopsis
- class GFoldMapSumConsByte tag f where
- gFoldMapSumConsByte :: (Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
- class GFoldMapCSumCtr tag f where
- gFoldMapCSumCtr :: f p -> GenericFoldMapM tag
- class GFoldMapCSumCtrArityByte tag (arity :: Natural) f where
- gFoldMapCSumCtrArityByte :: (Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag
- type family SumArity (a :: Type -> Type) :: Natural where ...
- type FitsInByte n = FitsInByteResult (n <=? 255)
- type family FitsInByteResult (b :: Bool) :: Constraint where ...
- type family TypeErrorMessage (a :: Symbol) :: Constraint where ...
Documentation
class GFoldMapSumConsByte tag f where Source #
gFoldMapSumConsByte :: (Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag Source #
Instances
class GFoldMapCSumCtr tag f where Source #
Sum type handler handling constructors only. Useful if you handle constructor prefixes elsewhere.
gFoldMapCSumCtr :: f p -> GenericFoldMapM tag Source #
Instances
(GFoldMapCSumCtr tag l, GFoldMapCSumCtr tag r) => GFoldMapCSumCtr (tag :: k1) (l :+: r :: k2 -> Type) Source # | |
Defined in Generic.Data.Function.FoldMap.SumConsByte gFoldMapCSumCtr :: forall (p :: k10). (l :+: r) p -> GenericFoldMapM tag Source # | |
GFoldMapC tag f => GFoldMapCSumCtr (tag :: k1) (C1 c f :: k2 -> Type) Source # | |
Defined in Generic.Data.Function.FoldMap.SumConsByte gFoldMapCSumCtr :: forall (p :: k10). C1 c f p -> GenericFoldMapM tag Source # |
class GFoldMapCSumCtrArityByte tag (arity :: Natural) f where Source #
gFoldMapCSumCtrArityByte :: (Word8 -> GenericFoldMapM tag) -> f p -> GenericFoldMapM tag Source #
Instances
(GFoldMapCSumCtrArityByte tag arity l, GFoldMapCSumCtrArityByte tag (arity + SumArity l) r) => GFoldMapCSumCtrArityByte (tag :: k) arity (l :+: r :: Type -> Type) Source # | |
Defined in Generic.Data.Function.FoldMap.SumConsByte gFoldMapCSumCtrArityByte :: forall (p :: k1). (Word8 -> GenericFoldMapM tag) -> (l :+: r) p -> GenericFoldMapM tag Source # | |
KnownNat arity => GFoldMapCSumCtrArityByte (tag :: k1) arity (C1 c f :: k2 -> Type) Source # | |
Defined in Generic.Data.Function.FoldMap.SumConsByte gFoldMapCSumCtrArityByte :: forall (p :: k10). (Word8 -> GenericFoldMapM tag) -> C1 c f p -> GenericFoldMapM tag Source # |
type FitsInByte n = FitsInByteResult (n <=? 255) Source #
type family FitsInByteResult (b :: Bool) :: Constraint where ... Source #
FitsInByteResult 'True = () | |
FitsInByteResult 'False = TypeErrorMessage "TODO ya type had more than 255 constructors" |
type family TypeErrorMessage (a :: Symbol) :: Constraint where ... Source #
TypeErrorMessage a = TypeError ('Text a) |