Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Generic-related utils.
Synopsis
- mkGenericTree :: (Natural -> a -> a -> a) -> NonEmpty a -> a
- mkGenericTreeVec :: HasCallStack => (a -> b) -> (Natural -> b -> b -> b) -> Vector a -> b
- type GenericTypeName a = GTypeName (GRep a)
- type family GRep t where ...
- type NiceGeneric t = (Generic t, GRep t ~ Rep t)
Documentation
mkGenericTree :: (Natural -> a -> a -> a) -> NonEmpty a -> a Source #
Rebuild a list into a binary tree of exactly the same form which Data.Generics uses to represent datatypes.
Along with the original list you have to provide constructor for intermediate nodes - it accepts zero-based index of the leftmost element of the right tree and merged trees themselves.
mkGenericTreeVec :: HasCallStack => (a -> b) -> (Natural -> b -> b -> b) -> Vector a -> b Source #
type GenericTypeName a = GTypeName (GRep a) Source #
Extract datatype name via its Generic representation.
For polymorphic types this throws away all type arguments.
type family GRep t where ... Source #
Like Rep
, but has better error messages when stuck.
Trying to use something requiring generics without the Generic
instance should
trigger a custom error message:
>>>
data Foo = Foo
>>>
(from . to :: GRep a ~ GRep () => a -> ()) Foo
... ... GHC.Generics.Rep Foo ... is stuck. Likely ... Generic Foo ... instance is missing or out of scope. ...>>>
data Foo = Foo deriving Generic
>>>
(from . to :: GRep a ~ GRep () => a -> ()) Foo
... ... Couldn't match type ‘"Foo"’ with ‘"()"’ ...