generic-data-functions-0.6.0: Familiar functions lifted to generic data types
Safe HaskellSafe-Inferred
LanguageGHC2021

Generic.Data.FOnCstr

Synopsis

Documentation

class GenericFOnCstr tag where Source #

What generic functor to run on the requested constructor.

Associated Types

type GenericFOnCstrF tag :: Type -> Type Source #

Functor.

type GenericFOnCstrC tag (dtName :: Symbol) (cstrName :: Symbol) (gf :: k -> Type) :: Constraint Source #

Constraint. Includes relevant generic meta (data type & constructor name).

Methods

genericFOnCstrF :: GenericFOnCstrC tag dtName cstrName gf => Proxy# '(dtName, cstrName) -> GenericFOnCstrF tag (gf p) Source #

Generic functor.

We have to pass a proxy thanks to type applications not working properly with instances. (This will be easier in GHC 9.10 via RequiredTypeArguments).

class GFOnCstr tag (name :: Symbol) gf where Source #

Run a generic functor (provided via tag) on the constructor name name.

We hope and pray that GHC removes the generic wrappers, at least the constructor ones, since we do a whole bunch of nothing with them on the term level. Checking this (the produced Core) is a big TODO.

Methods

gFOnCstr :: GenericFOnCstrF tag (gf p) Source #

Instances

Instances details
(turns ~ AssertValidCstrPath dtName cstrName (GCstrPath cstrName gf), Functor (GenericFOnCstrF tag), GFOnCstr' tag dtName cstrName turns gf) => GFOnCstr (tag :: k2) cstrName (D1 ('MetaData dtName _md2 _md3 _md4) gf :: k1 -> Type) Source # 
Instance details

Defined in Generic.Data.FOnCstr

Methods

gFOnCstr :: forall (p :: k10). GenericFOnCstrF tag (D1 ('MetaData dtName _md2 _md3 _md4) gf p) Source #

type family AssertValidCstrPath dtName cstr eae where ... Source #

Equations

AssertValidCstrPath dtName cstr (Right a) = a 
AssertValidCstrPath dtName cstr (Left e) = TypeError (((((Text "error searching for constructor " :<>: Text cstr) :<>: Text " in data type ") :<>: Text dtName) :<>: Text ":") :$$: e) 

class GFOnCstr' tag (dtName :: Symbol) (cstrName :: Symbol) (turns :: [GCstrChoice]) gf where Source #

Methods

gFOnCstr' :: GenericFOnCstrF tag (gf p) Source #

Instances

Instances details
(Functor (GenericFOnCstrF tag), GenericFOnCstr tag, GenericFOnCstrC tag dtName cstrName gf) => GFOnCstr' (tag :: k1) dtName cstrName ('[] :: [GCstrChoice]) (C1 mc gf :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.FOnCstr

Methods

gFOnCstr' :: forall (p :: k10). GenericFOnCstrF tag (C1 mc gf p) Source #

(Functor (GenericFOnCstrF tag), GFOnCstr' tag dtName cstrName turns l) => GFOnCstr' (tag :: k1) dtName cstrName ('GoL1 ': turns) (l :+: r :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.FOnCstr

Methods

gFOnCstr' :: forall (p :: k10). GenericFOnCstrF tag ((l :+: r) p) Source #

(Functor (GenericFOnCstrF tag), GFOnCstr' tag dtName cstrName turns r) => GFOnCstr' (tag :: k1) dtName cstrName ('GoR1 ': turns) (l :+: r :: k2 -> Type) Source # 
Instance details

Defined in Generic.Data.FOnCstr

Methods

gFOnCstr' :: forall (p :: k10). GenericFOnCstrF tag ((l :+: r) p) Source #

genericFOnCstr :: forall tag (name :: Symbol) a. (Generic a, Functor (GenericFOnCstrF tag), GFOnCstr tag name (Rep a)) => GenericFOnCstrF tag a Source #

Run a generic functor on the requested constructor of the given type.