-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utilities for GHC.Generics -- -- This package provides common functions on generic types. See README. @package generic-data @version 0.1.0.0 module Generic.Data.Internal.Compat -- | Lift the standard readPrec and readListPrec functions -- through the type constructor. readPrec1 :: (Read1 f, Read a) => ReadPrec f a -- | Defunctionalization -- -- See -- https://hackage.haskell.org/package/singletons-2.4.1/docs/src/Data-Singletons-Internal.html#TyFun -- -- A copy of the defunctionalization implementation in the singletons -- package, to not pull in too heavy dependencies. module Generic.Data.Internal.Defun data TyFun :: Type -> Type -> Type -- | Kind of function symbols type a ~> b = TyFun a b -> Type -- | Type constructor function symbol data TyCon :: (k1 -> k2) -> TyFun k1 k2 -> Type -- | Identity function symbol data Id :: TyFun k1 k2 -> Type -- | Constant function symbol data Const :: k2 -> TyFun k1 k2 -> Type module Generic.Data.Internal.Enum -- | Generic toEnum. -- --
-- instance Enum MyType where -- toEnum = gtoEnum -- fromEnum = gfromEnum --gtoEnum :: forall a. (Generic a, GEnum (Rep a)) => Int -> a -- | Generic fromEnum. -- -- See also gtoEnum. gfromEnum :: (Generic a, GEnum (Rep a)) => a -> Int -- | Generic minBound. -- --
-- instance Bounded MyType where -- minBound = gminBound -- maxBound = gmaxBound --gminBound :: (Generic a, GBounded (Rep a)) => a -- | Generic maxBound. -- -- See also gminBound. gmaxBound :: (Generic a, GBounded (Rep a)) => a -- | Generic representation of Enum types. class GEnum f gCardinality :: GEnum f => proxy f -> Int gFromEnum :: GEnum f => f p -> Int gToEnum :: GEnum f => Int -> f p -- | Generic representation of Bounded types. class GBounded f gMinBound :: GBounded f => f p gMaxBound :: GBounded f => f p instance Generic.Data.Internal.Enum.GBounded f => Generic.Data.Internal.Enum.GBounded (GHC.Generics.M1 i c f) instance Generic.Data.Internal.Enum.GBounded GHC.Generics.U1 instance GHC.Enum.Bounded c => Generic.Data.Internal.Enum.GBounded (GHC.Generics.K1 i c) instance (Generic.Data.Internal.Enum.GBounded f, Generic.Data.Internal.Enum.GBounded g) => Generic.Data.Internal.Enum.GBounded (f GHC.Generics.:+: g) instance (Generic.Data.Internal.Enum.GBounded f, Generic.Data.Internal.Enum.GBounded g) => Generic.Data.Internal.Enum.GBounded (f GHC.Generics.:*: g) instance Generic.Data.Internal.Enum.GEnum f => Generic.Data.Internal.Enum.GEnum (GHC.Generics.M1 i c f) instance (Generic.Data.Internal.Enum.GEnum f, Generic.Data.Internal.Enum.GEnum g) => Generic.Data.Internal.Enum.GEnum (f GHC.Generics.:+: g) instance Generic.Data.Internal.Enum.GEnum GHC.Generics.U1 -- | Type level functions on generic representations. module Generic.Data.Internal.Functions -- | Apply a type function on every field of a type. -- | Number of constructors of a data type. nconstructors :: forall r. KnownNat (NConstructors r) => Integer -- | Arity of a constructor. nfields :: forall r. KnownNat (NFields r) => Integer -- | Type metadata accessors -- -- Type names, constructor names... module Generic.Data.Internal.Meta -- | Name of the first data constructor in a type as a string. -- --
-- gdatatypeName @(Maybe AnyType) = "Maybe" --gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | Name of the module where the first type constructor is defined. -- --
-- gmoduleName @(Maybe AnyType) = "GHC.Base" --gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | Name of the package where the first type constructor is defined. -- --
-- gpackageName @(Maybe AnyType) = "base" --gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | True if the first type constructor is a newtype. gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool fromDatatype :: forall d r. Datatype d => (M1 D d Proxy () -> r) -> r -- | Generic representations that contain datatype metadata. class GDatatype f gDatatypeName :: GDatatype f => String gModuleName :: GDatatype f => String gPackageName :: GDatatype f => String gIsNewtype :: GDatatype f => Bool -- | Name of the first constructor in a value. -- --
-- gconName (Just 0) = "Just" --gconName :: forall a. Constructors a => a -> String -- | The fixity of the first constructor. -- --
-- gconFixity (Just 0) = Prefix -- gconFixity ([] :*: id) = Infix RightAssociative 6 --gconFixity :: forall a. Constructors a => a -> Fixity -- | True if the constructor is a record. -- --
-- gconIsRecord (Just 0) = False
-- gconIsRecord (Sum 0) = True
-- -- newtype Sum a = Sum { getSum :: a }
--
gconIsRecord :: forall a. Constructors a => a -> Bool
-- | Number of constructors.
--
-- -- gconNum @(Maybe AnyType) = 2 --gconNum :: forall a. Constructors a => Int -- | An opaque identifier for a constructor. newtype ConId a ConId :: Int -> ConId a conIdToInt :: forall a. ConId a -> Int conIdEnum :: forall a. Constructors a => [ConId a] conIdToString :: forall a. Constructors a => ConId a -> String conId :: forall a. Constructors a => a -> ConId a conIdMax :: forall a. Constructors a => ConId a -- | Constraint synonym for Generic and GConstructor. class (Generic a, GConstructors (Rep a)) => Constructors a newtype GConId r GConId :: Int -> GConId r gConIdToInt :: GConId r -> Int toConId :: forall a. Generic a => GConId (Rep a) -> ConId a fromConId :: forall a. Generic a => ConId a -> GConId (Rep a) reGConId :: GConId r -> GConId s gConIdMax :: forall r. GConstructors r => GConId r -- | Generic representations that contain constructor metadata. class GConstructors r gConIdToString :: GConstructors r => GConId r -> String gConId :: GConstructors r => r p -> GConId r gConNum :: GConstructors r => Int gConFixity :: GConstructors r => r p -> Fixity gConIsRecord :: GConstructors r => r p -> Bool instance forall k (r :: k). GHC.Classes.Ord (Generic.Data.Internal.Meta.GConId r) instance forall k (r :: k). GHC.Classes.Eq (Generic.Data.Internal.Meta.GConId r) instance forall k (a :: k). GHC.Classes.Ord (Generic.Data.Internal.Meta.ConId a) instance forall k (a :: k). GHC.Classes.Eq (Generic.Data.Internal.Meta.ConId a) instance (GHC.Generics.Generic a, Generic.Data.Internal.Meta.GConstructors (GHC.Generics.Rep a)) => Generic.Data.Internal.Meta.Constructors a instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Generic.Data.Internal.Meta.GConstructors f => Generic.Data.Internal.Meta.GConstructors (GHC.Generics.M1 GHC.Generics.D c f) instance forall k (f :: k -> *) (g :: k -> *). (Generic.Data.Internal.Meta.GConstructors f, Generic.Data.Internal.Meta.GConstructors g) => Generic.Data.Internal.Meta.GConstructors (f GHC.Generics.:+: g) instance forall k (c :: GHC.Generics.Meta) (f :: k -> *). GHC.Generics.Constructor c => Generic.Data.Internal.Meta.GConstructors (GHC.Generics.M1 GHC.Generics.C c f) instance forall k (d :: GHC.Generics.Meta) (f :: k -> *). GHC.Generics.Datatype d => Generic.Data.Internal.Meta.GDatatype (GHC.Generics.M1 GHC.Generics.D d f) -- | Generic deriving for standard classes in base module Generic.Data.Internal.Prelude -- | Generic (==). -- --
-- instance Eq MyType where -- (==) = geq --geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool -- | Generic compare. -- --
-- instance Ord MyType where -- compare = gcompare --gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering -- | Generic (<>) (or mappend). -- --
-- instance Semigroup MyType where -- (<>) = gmappend ---- -- See also gmempty. gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a -- | Generic mempty. -- --
-- instance Monoid MyType where -- mempty = gmempty --gmempty :: (Generic a, Monoid (Rep a ())) => a -- | Generic (<>) (or mappend). -- -- The difference from gmappend is the Monoid constraint -- instead of Semigroup, for older versions of base where -- Semigroup is not a superclass of Monoid. gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a -- | Generic fmap. -- --
-- instance Functor MyTypeF where -- fmap = gfmap --gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b -- | Generic (<$). -- -- See also gfmap. gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a -- | Generic pure. -- --
-- instance Applicative MyTypeF where -- pure = gpure -- (<*>) = gap --gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a -- | Generic (<*>) (or ap). -- -- See also gpure. gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b -- | Generic liftA2. -- -- See also gpure. gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c -- | Generic empty. -- --
-- instance Alternative MyTypeF where -- empty = gempty -- (<|>) = galt --gempty :: (Generic1 f, Alternative (Rep1 f)) => f a -- | Generic (<|>). -- -- See also gempty. galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a -- | Generic foldMap. -- --
-- instance Foldable MyTypeF where -- foldMap = gfoldMap --gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m -- | Generic foldr. -- --
-- instance Foldable MyTypeF where -- foldr = gfoldr ---- -- See also gfoldMap. gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b -- | Generic traverse. -- --
-- instance Traversable MyTypeF where -- traverse = gtraverse --gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b) -- | Generic sequenceA. -- --
-- instance Traversable MyTypeF where -- sequenceA = gsequenceA ---- -- See also gtraverse. gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a) -- | Generic liftEq. gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool -- | Generic liftCompare. gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering -- | A helper for better type inference. from' :: Generic a => a -> Rep a () -- | A helper for better type inference. to' :: Generic a => Rep a () -> a -- | Lift binary combinators generically. liftG2 :: Generic1 f => (Rep1 f a -> Rep1 f b -> Rep1 f c) -> f a -> f b -> f c module Generic.Data.Internal.Resolvers -- | A newtype whose instances for simple classes (Eq, Ord, -- Read, Show) use higher-kinded class instances for -- f (Eq1, Ord1, Read1, Show1). newtype Id1 f a Id1 :: f a -> Id1 f a [unId1] :: Id1 f a -> f a -- | A newtype with trivial instances, that considers every value -- equivalent to every other one, and shows as just "_". newtype Opaque a Opaque :: a -> Opaque a [unOpaque] :: Opaque a -> a -- | All equal. -- | All equal. -- | Shown as "_". -- | All equal. -- | All equal. -- | Shown as "_". -- | A higher-kinded version of Opaque. newtype Opaque1 f a Opaque1 :: f a -> Opaque1 f a [unOpaque1] :: Opaque1 f a -> f a -- | All equal. -- | All equal. -- | Shown as "_". -- | All equal. -- | All equal. -- | Shown as "_". instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Generic.Data.Internal.Resolvers.Id1 f) instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Generic.Data.Internal.Resolvers.Id1 f) instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Resolvers.Id1 f) instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Resolvers.Id1 f) instance GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Opaque1 f a) instance GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Opaque1 f a) instance GHC.Show.Show (Generic.Data.Internal.Resolvers.Opaque1 f a) instance Data.Functor.Classes.Eq1 (Generic.Data.Internal.Resolvers.Opaque1 f) instance Data.Functor.Classes.Ord1 (Generic.Data.Internal.Resolvers.Opaque1 f) instance Data.Functor.Classes.Show1 (Generic.Data.Internal.Resolvers.Opaque1 f) instance GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Opaque a) instance GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Opaque a) instance GHC.Show.Show (Generic.Data.Internal.Resolvers.Opaque a) instance Data.Functor.Classes.Eq1 Generic.Data.Internal.Resolvers.Opaque instance Data.Functor.Classes.Ord1 Generic.Data.Internal.Resolvers.Opaque instance Data.Functor.Classes.Show1 Generic.Data.Internal.Resolvers.Opaque instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Generic.Data.Internal.Resolvers.Id1 f a) instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Generic.Data.Internal.Resolvers.Id1 f a) instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Generic.Data.Internal.Resolvers.Id1 f a) instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Generic.Data.Internal.Resolvers.Id1 f a) module Generic.Data.Internal.Show -- | Generic showsPrec. -- --
-- instance Show MyType where -- showsPrec = gshowsPrec --gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS gprecShows :: (Generic a, GShow0 (Rep a)) => a -> PrecShowS -- | Generic representation of Show types. type GShow0 = GShow Proxy gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS gLiftPrecShows :: GShow1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> f a -> PrecShowS type ShowsPrec a = (Int -> a -> ShowS, [a] -> ShowS) -- | Generic representation of Show1 types. type GShow1 = GShow Identity class GShow p f gPrecShows :: GShow p f => p (ShowsPrec a) -> f a -> PrecShowS class GShowC p c f gPrecShowsC :: GShowC p c f => p (ShowsPrec a) -> String -> Fixity -> M1 C c f a -> PrecShowS class GShowFields p f gPrecShowsFields :: GShowFields p f => p (ShowsPrec a) -> f a -> [PrecShowS] class GShowNamed p f gPrecShowsNamed :: GShowNamed p f => p (ShowsPrec a) -> f a -> ShowFields class GShowSingle p f gPrecShowsSingle :: GShowSingle p f => p (ShowsPrec a) -> f a -> PrecShowS instance Generic.Data.Internal.Show.GShowSingle p f => Generic.Data.Internal.Show.GShowFields p (GHC.Generics.M1 GHC.Generics.S c f) instance (GHC.Generics.Selector c, Generic.Data.Internal.Show.GShowSingle p f) => Generic.Data.Internal.Show.GShowNamed p (GHC.Generics.M1 GHC.Generics.S c f) instance GHC.Show.Show a => Generic.Data.Internal.Show.GShowSingle p (GHC.Generics.K1 i a) instance Data.Functor.Classes.Show1 f => Generic.Data.Internal.Show.GShowSingle Data.Functor.Identity.Identity (GHC.Generics.Rec1 f) instance Generic.Data.Internal.Show.GShowSingle Data.Functor.Identity.Identity GHC.Generics.Par1 instance (Generic.Data.Internal.Show.GShowSingle Data.Functor.Identity.Identity f, Generic.Data.Internal.Show.GShowSingle p g) => Generic.Data.Internal.Show.GShowSingle p (f GHC.Generics.:.: g) instance Generic.Data.Internal.Show.GShowNamed p f => Generic.Data.Internal.Show.GShowC p ('GHC.Generics.MetaCons s y 'GHC.Types.True) f instance (Generic.Data.Internal.Show.GShowNamed p f, Generic.Data.Internal.Show.GShowNamed p g) => Generic.Data.Internal.Show.GShowNamed p (f GHC.Generics.:*: g) instance Generic.Data.Internal.Show.GShowNamed p GHC.Generics.U1 instance Generic.Data.Internal.Show.GShowFields p f => Generic.Data.Internal.Show.GShowC p ('GHC.Generics.MetaCons s y 'GHC.Types.False) f instance (Generic.Data.Internal.Show.GShowFields p f, Generic.Data.Internal.Show.GShowFields p g) => Generic.Data.Internal.Show.GShowFields p (f GHC.Generics.:*: g) instance Generic.Data.Internal.Show.GShowFields p GHC.Generics.U1 instance (GHC.Generics.Constructor c, Generic.Data.Internal.Show.GShowC p c f) => Generic.Data.Internal.Show.GShow p (GHC.Generics.M1 GHC.Generics.C c f) instance Generic.Data.Internal.Show.GShow p f => Generic.Data.Internal.Show.GShow p (GHC.Generics.M1 GHC.Generics.D d f) instance (Generic.Data.Internal.Show.GShow p f, Generic.Data.Internal.Show.GShow p g) => Generic.Data.Internal.Show.GShow p (f GHC.Generics.:+: g) instance Generic.Data.Internal.Show.GShow p GHC.Generics.V1 -- | Newtypes with instances implemented using generic combinators. module Generic.Data.Internal.Newtype -- | Type with instances derived via Generic. newtype Generically a Generically :: a -> Generically a [unGenerically] :: Generically a -> a -- | Type with instances derived via Generic1. newtype Generically1 f a Generically1 :: f a -> Generically1 f a [unGenerically1] :: Generically1 f a -> f a instance GHC.Generics.Generic (f a) => GHC.Generics.Generic (Generic.Data.Internal.Newtype.Generically1 f a) instance GHC.Generics.Generic1 f => GHC.Generics.Generic1 (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Eq1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Eq1 (GHC.Generics.Rep1 f), GHC.Classes.Eq a) => GHC.Classes.Eq (Generic.Data.Internal.Newtype.Generically1 f a) instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Ord1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Data.Functor.Classes.Ord1 (GHC.Generics.Rep1 f), GHC.Classes.Ord a) => GHC.Classes.Ord (Generic.Data.Internal.Newtype.Generically1 f a) instance (GHC.Generics.Generic1 f, Generic.Data.Internal.Show.GShow1 (GHC.Generics.Rep1 f)) => Data.Functor.Classes.Show1 (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Generic.Data.Internal.Show.GShow1 (GHC.Generics.Rep1 f), GHC.Show.Show a) => GHC.Show.Show (Generic.Data.Internal.Newtype.Generically1 f a) instance (GHC.Generics.Generic1 f, GHC.Base.Functor (GHC.Generics.Rep1 f)) => GHC.Base.Functor (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, GHC.Base.Applicative (GHC.Generics.Rep1 f)) => GHC.Base.Applicative (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, GHC.Base.Alternative (GHC.Generics.Rep1 f)) => GHC.Base.Alternative (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Data.Foldable.Foldable (GHC.Generics.Rep1 f)) => Data.Foldable.Foldable (Generic.Data.Internal.Newtype.Generically1 f) instance (GHC.Generics.Generic1 f, Data.Traversable.Traversable (GHC.Generics.Rep1 f)) => Data.Traversable.Traversable (Generic.Data.Internal.Newtype.Generically1 f) instance GHC.Generics.Generic a => GHC.Generics.Generic (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, GHC.Classes.Eq (GHC.Generics.Rep a ())) => GHC.Classes.Eq (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, GHC.Classes.Ord (GHC.Generics.Rep a ())) => GHC.Classes.Ord (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, Generic.Data.Internal.Show.GShow0 (GHC.Generics.Rep a)) => GHC.Show.Show (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, Data.Semigroup.Semigroup (GHC.Generics.Rep a ())) => Data.Semigroup.Semigroup (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, GHC.Base.Monoid (GHC.Generics.Rep a ())) => GHC.Base.Monoid (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, Generic.Data.Internal.Enum.GEnum (GHC.Generics.Rep a)) => GHC.Enum.Enum (Generic.Data.Internal.Newtype.Generically a) instance (GHC.Generics.Generic a, Generic.Data.Internal.Enum.GBounded (GHC.Generics.Rep a)) => GHC.Enum.Bounded (Generic.Data.Internal.Newtype.Generically a) -- | Generic representations as data types. module Generic.Data.Internal.Data -- | A wrapper to view a generic Rep as the datatype it's supposed -- to represent, without needing a declaration. -- -- This can be used to derive types from generic types, and get some -- instances for free, in particular Generic, Show, -- Enum, Bounded. newtype Data r p Data :: r p -> Data r p [unData] :: Data r p -> r p instance GHC.Base.Monoid (r p) => GHC.Base.Monoid (Generic.Data.Internal.Data.Data r p) instance Data.Semigroup.Semigroup (r p) => Data.Semigroup.Semigroup (Generic.Data.Internal.Data.Data r p) instance Data.Functor.Classes.Ord1 r => Data.Functor.Classes.Ord1 (Generic.Data.Internal.Data.Data r) instance Data.Functor.Classes.Eq1 r => Data.Functor.Classes.Eq1 (Generic.Data.Internal.Data.Data r) instance GHC.Classes.Ord (r p) => GHC.Classes.Ord (Generic.Data.Internal.Data.Data r p) instance GHC.Classes.Eq (r p) => GHC.Classes.Eq (Generic.Data.Internal.Data.Data r p) instance Data.Functor.Contravariant.Contravariant r => Data.Functor.Contravariant.Contravariant (Generic.Data.Internal.Data.Data r) instance GHC.Base.MonadPlus r => GHC.Base.MonadPlus (Generic.Data.Internal.Data.Data r) instance GHC.Base.Monad r => GHC.Base.Monad (Generic.Data.Internal.Data.Data r) instance GHC.Base.Alternative r => GHC.Base.Alternative (Generic.Data.Internal.Data.Data r) instance GHC.Base.Applicative r => GHC.Base.Applicative (Generic.Data.Internal.Data.Data r) instance Data.Traversable.Traversable r => Data.Traversable.Traversable (Generic.Data.Internal.Data.Data r) instance Data.Foldable.Foldable r => Data.Foldable.Foldable (Generic.Data.Internal.Data.Data r) instance GHC.Base.Functor r => GHC.Base.Functor (Generic.Data.Internal.Data.Data r) instance (GHC.Base.Functor r, Data.Functor.Contravariant.Contravariant r) => GHC.Generics.Generic (Generic.Data.Internal.Data.Data r p) instance GHC.Generics.Generic1 (Generic.Data.Internal.Data.Data r) instance (Generic.Data.Internal.Show.GShow1 r, GHC.Show.Show p) => GHC.Show.Show (Generic.Data.Internal.Data.Data r p) instance Generic.Data.Internal.Show.GShow1 r => Data.Functor.Classes.Show1 (Generic.Data.Internal.Data.Data r) instance Generic.Data.Internal.Enum.GEnum r => GHC.Enum.Enum (Generic.Data.Internal.Data.Data r p) instance Generic.Data.Internal.Enum.GBounded r => GHC.Enum.Bounded (Generic.Data.Internal.Data.Data r p) -- | Generic combinators to derive type class instances. -- -- base classes that GHC can not derive instances for, as of -- version 8.2: -- --
-- instance Semigroup MyType where -- (<>) = gmappend ---- -- See also gmempty. gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a -- | Generic mempty. -- --
-- instance Monoid MyType where -- mempty = gmempty --gmempty :: (Generic a, Monoid (Rep a ())) => a -- | Generic (<>) (or mappend). -- -- The difference from gmappend is the Monoid constraint -- instead of Semigroup, for older versions of base where -- Semigroup is not a superclass of Monoid. gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a -- | Generic (==). -- --
-- instance Eq MyType where -- (==) = geq --geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool -- | Generic compare. -- --
-- instance Ord MyType where -- compare = gcompare --gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering -- | Generic showsPrec. -- --
-- instance Show MyType where -- showsPrec = gshowsPrec --gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS -- | Generic representation of Show types. type GShow0 = GShow Proxy -- | Generic fromEnum. -- -- See also gtoEnum. gfromEnum :: (Generic a, GEnum (Rep a)) => a -> Int -- | Generic toEnum. -- --
-- instance Enum MyType where -- toEnum = gtoEnum -- fromEnum = gfromEnum --gtoEnum :: forall a. (Generic a, GEnum (Rep a)) => Int -> a -- | Generic representation of Enum types. class GEnum f -- | Generic minBound. -- --
-- instance Bounded MyType where -- minBound = gminBound -- maxBound = gmaxBound --gminBound :: (Generic a, GBounded (Rep a)) => a -- | Generic maxBound. -- -- See also gminBound. gmaxBound :: (Generic a, GBounded (Rep a)) => a -- | Generic representation of Bounded types. class GBounded f -- | Generic fmap. -- --
-- instance Functor MyTypeF where -- fmap = gfmap --gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b -- | Generic (<$). -- -- See also gfmap. gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a -- | Generic foldMap. -- --
-- instance Foldable MyTypeF where -- foldMap = gfoldMap --gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m -- | Generic foldr. -- --
-- instance Foldable MyTypeF where -- foldr = gfoldr ---- -- See also gfoldMap. gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b -- | Generic traverse. -- --
-- instance Traversable MyTypeF where -- traverse = gtraverse --gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b) -- | Generic sequenceA. -- --
-- instance Traversable MyTypeF where -- sequenceA = gsequenceA ---- -- See also gtraverse. gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a) -- | Generic pure. -- --
-- instance Applicative MyTypeF where -- pure = gpure -- (<*>) = gap --gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a -- | Generic (<*>) (or ap). -- -- See also gpure. gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b -- | Generic liftA2. -- -- See also gpure. gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c -- | Generic empty. -- --
-- instance Alternative MyTypeF where -- empty = gempty -- (<|>) = galt --gempty :: (Generic1 f, Alternative (Rep1 f)) => f a -- | Generic (<|>). -- -- See also gempty. galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a -- | Generic liftEq. gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool -- | Generic liftCompare. gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS -- | Generic representation of Show1 types. type GShow1 = GShow Identity -- | A newtype whose instances for simple classes (Eq, Ord, -- Read, Show) use higher-kinded class instances for -- f (Eq1, Ord1, Read1, Show1). newtype Id1 f a Id1 :: f a -> Id1 f a [unId1] :: Id1 f a -> f a -- | A newtype with trivial instances, that considers every value -- equivalent to every other one, and shows as just "_". newtype Opaque a Opaque :: a -> Opaque a [unOpaque] :: Opaque a -> a -- | A higher-kinded version of Opaque. newtype Opaque1 f a Opaque1 :: f a -> Opaque1 f a [unOpaque1] :: Opaque1 f a -> f a -- | Type with instances derived via Generic. newtype Generically a Generically :: a -> Generically a [unGenerically] :: Generically a -> a -- | Type with instances derived via Generic1. newtype Generically1 f a Generically1 :: f a -> Generically1 f a [unGenerically1] :: Generically1 f a -> f a -- | Name of the first data constructor in a type as a string. -- --
-- gdatatypeName @(Maybe AnyType) = "Maybe" --gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | Name of the module where the first type constructor is defined. -- --
-- gmoduleName @(Maybe AnyType) = "GHC.Base" --gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | Name of the package where the first type constructor is defined. -- --
-- gpackageName @(Maybe AnyType) = "base" --gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String -- | True if the first type constructor is a newtype. gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool -- | Generic representations that contain datatype metadata. class GDatatype f -- | Name of the first constructor in a value. -- --
-- gconName (Just 0) = "Just" --gconName :: forall a. Constructors a => a -> String -- | The fixity of the first constructor. -- --
-- gconFixity (Just 0) = Prefix -- gconFixity ([] :*: id) = Infix RightAssociative 6 --gconFixity :: forall a. Constructors a => a -> Fixity -- | True if the constructor is a record. -- --
-- gconIsRecord (Just 0) = False
-- gconIsRecord (Sum 0) = True
-- -- newtype Sum a = Sum { getSum :: a }
--
gconIsRecord :: forall a. Constructors a => a -> Bool
-- | Number of constructors.
--
-- -- gconNum @(Maybe AnyType) = 2 --gconNum :: forall a. Constructors a => Int -- | Constraint synonym for Generic and GConstructor. class (Generic a, GConstructors (Rep a)) => Constructors a -- | Generic representations that contain constructor metadata. class GConstructors r module Generic.Data.Orphans instance Data.Semigroup.Semigroup c => Data.Semigroup.Semigroup (GHC.Generics.K1 i c p) instance GHC.Base.Monoid c => GHC.Base.Monoid (GHC.Generics.K1 i c p) instance Data.Semigroup.Semigroup (f p) => Data.Semigroup.Semigroup (GHC.Generics.M1 i c f p) instance GHC.Base.Monoid (f p) => GHC.Base.Monoid (GHC.Generics.M1 i c f p) instance Data.Semigroup.Semigroup p => Data.Semigroup.Semigroup (GHC.Generics.Par1 p) instance GHC.Base.Monoid p => GHC.Base.Monoid (GHC.Generics.Par1 p) instance Data.Semigroup.Semigroup (f p) => Data.Semigroup.Semigroup (GHC.Generics.Rec1 f p) instance GHC.Base.Monoid (f p) => GHC.Base.Monoid (GHC.Generics.Rec1 f p) instance Data.Semigroup.Semigroup (f (g p)) => Data.Semigroup.Semigroup ((GHC.Generics.:.:) f g p) instance GHC.Base.Monoid (f (g p)) => GHC.Base.Monoid ((GHC.Generics.:.:) f g p) instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (GHC.Generics.M1 i c f) instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (GHC.Generics.M1 i c f) instance GHC.Base.Monoid c => GHC.Base.Applicative (GHC.Generics.K1 i c) instance Data.Semigroup.Semigroup (GHC.Generics.V1 p) instance Data.Semigroup.Semigroup (GHC.Generics.U1 p) instance GHC.Base.Monoid (GHC.Generics.U1 p) instance (Data.Semigroup.Semigroup (f p), Data.Semigroup.Semigroup (g p)) => Data.Semigroup.Semigroup ((GHC.Generics.:*:) f g p) instance (GHC.Base.Monoid (f p), GHC.Base.Monoid (g p)) => GHC.Base.Monoid ((GHC.Generics.:*:) f g p) instance Data.Functor.Classes.Eq1 GHC.Generics.V1 instance Data.Functor.Classes.Ord1 GHC.Generics.V1 instance Data.Functor.Classes.Eq1 GHC.Generics.U1 instance Data.Functor.Classes.Ord1 GHC.Generics.U1 instance GHC.Classes.Eq c => Data.Functor.Classes.Eq1 (GHC.Generics.K1 i c) instance GHC.Classes.Ord c => Data.Functor.Classes.Ord1 (GHC.Generics.K1 i c) instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:*: g) instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:*: g) instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:+: g) instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:+: g) instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (GHC.Generics.Rec1 f) instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (GHC.Generics.Rec1 f) instance Data.Functor.Classes.Eq1 GHC.Generics.Par1 instance Data.Functor.Classes.Ord1 GHC.Generics.Par1 instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (f GHC.Generics.:.: g) instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (f GHC.Generics.:.: g) -- | Utilities to derive and transform generic types. module Generic.Data.Types -- | A wrapper to view a generic Rep as the datatype it's supposed -- to represent, without needing a declaration. -- -- This can be used to derive types from generic types, and get some -- instances for free, in particular Generic, Show, -- Enum, Bounded. newtype Data r p Data :: r p -> Data r p [unData] :: Data r p -> r p -- | Apply a type function on every field of a type. data TyFun :: Type -> Type -> Type -- | Kind of function symbols type a ~> b = TyFun a b -> Type -- | Identity function symbol data Id :: TyFun k1 k2 -> Type -- | Type constructor function symbol data TyCon :: (k1 -> k2) -> TyFun k1 k2 -> Type -- | Constant function symbol data Const :: k2 -> TyFun k1 k2 -> Type