morley-1.20.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Util.Generic

Description

Generic-related utils.

Synopsis

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 ‘"()"’
...

Equations

GRep ThisTypeShallNotBeExported = TypeError ('Text "impossible") 
GRep t = IfStuck (Rep t) (TypeError (GRepErrorMsg t)) (Pure (Rep t)) 

type NiceGeneric t = (Generic t, GRep t ~ Rep t) Source #

Similar to Generic, but also asserts that GRep is the same as Rep. Useful in place of Generic when GRep is used.