generic-data-1.1.0.2: Deriving instances with GHC.Generics and related utilities

Safe Haskell | Safe-Inferred
Language | Haskell2010

Generic.Data.Internal.Functions

Description

Type-level functions on generic representations.

### Warning

This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time.

If something here seems useful, please report it or create a pull request to export it from an external module.

Synopsis

- type family NConstructors (r :: k -> Type) :: Nat
- nconstructors :: forall {k} (r :: k -> Type). KnownNat (NConstructors r) => Integer
- type family NFields (r :: k -> Type) :: Nat
- nfields :: forall {k} (r :: k -> Type). KnownNat (NFields r) => Integer

# Documentation

type family NConstructors (r :: k -> Type) :: Nat Source #

Number of constructors of a data type.

#### Instances

Instances details

type NConstructors (f :+: g :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NConstructors (f :+: g :: k -> Type) = NConstructors f + NConstructors g
type NConstructors (M1 C c f :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NConstructors (M1 C c f :: k -> Type) = 1
type NConstructors (M1 D c f :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NConstructors (M1 D c f :: k -> Type) = NConstructors f

nconstructors :: forall {k} (r :: k -> Type). KnownNat (NConstructors r) => Integer Source #

Number of constructors of a data type.

type family NFields (r :: k -> Type) :: Nat Source #

Arity of a constructor.

#### Instances

Instances details

type NFields (f :*: g :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NFields (f :*: g :: k -> Type) = NFields f + NFields g
type NFields (M1 C c f :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NFields (M1 C c f :: k -> Type) = NFields f
type NFields (M1 S c f :: k -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Functions type NFields (M1 S c f :: k -> Type) = 1

nfields :: forall {k} (r :: k -> Type). KnownNat (NFields r) => Integer Source #

Arity of a constructor.