-- | Surgery for generic data types: -- remove and insert constructors and fields. -- -- Functions in this module are expected to be used with visible type -- applications. Surgeries have a lot of type parameters, but usually only the -- first one to three type arguments need to be passed via @TypeApplications@. -- Functions are annotated with \"functional dependencies\", with a meaning -- similar to the homonymous GHC extension for type classes (click on -- \"Details\" under each function to see those). -- -- Remember that not all parameters to the left of a functional dependency -- arrow need to be annotated explicitly to determine those on the right. Some -- can also be inferred from the context. -- -- Note that constructors and fields are indexed from zero. module Generic.Data.Surgery ( -- * Surgeries from generic-data and generic-lens -- -- | The library -- has a "Generic.Data.Microsurgery" module (since 0.4.0.0) to modify some -- metadata of generic representations. -- -- See also the documentation in that module about surgeries using -- , -- when you want to /update/ fields, rather than remove or insert them. -- * Synthetic data types Data , toData , fromData -- * Surgeries -- ** Getting into the operating room , OR , toOR , fromOR' , toOR' , fromOR , OROf -- ** Unnamed fields , removeCField , insertCField , insertCField' , modifyCField -- ** Named fields (records) , removeRField , insertRField , insertRField' , modifyRField -- ** Constructors -- | A constructor is extracted to a "tuple", which can be any -- 'GHC.Generics.Generic' single-constructor type with the same number of -- fields. -- -- Note that @()@ and 'Data.Functor.Identity.Identity' can be used as an -- empty and a singleton tuple type respectively. -- -- When the tuple type can't be inferred and doesn't really matter, -- an alternative to explicit type annotations is to use the @...ConstrT@ -- variants of these surgeries, which are specialized to actual tuples -- (@()@, 'Data.Functor.Identity.Identity', @(,)@, @(,,)@, up to 7 --- -- because that's where 'GHC.Generics.Generic' instances currently stop). , removeConstr , insertConstr , modifyConstr , removeConstrT , insertConstrT , modifyConstrT -- * Constraint synonyms -- | Hiding implementation details from the signatures above. -- Useful to compose surgeries in a reusable way. -- ** Conversions , ToORRep , ToOR , FromORRep , FromOR -- ** Surgeries , RmvCField , InsCField , ModCField , RmvRField , InsRField , ModRField , RmvConstr , InsConstr , ModConstr , RmvConstrT , InsConstrT , ModConstrT ) where import Generic.Data.Types (Data(..), toData, fromData) import Generic.Data.Surgery.Internal