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

Safe Haskell | Safe-Inferred
Language | Haskell2010

Generic.Data.Internal.Error

Description

Error messages.

### 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 HasSum (f :: Type -> Type) :: Bool where ...
- class Assert (pred :: Bool) (msg :: ErrorMessage)
- type AssertNoSum (constraint :: Type -> Constraint) a = Assert (Not (HasSum (Rep a))) (((('Text "Cannot derive " ':<>: 'ShowType constraint) ':<>: 'Text " instance for ") ':<>: 'ShowType a) ':<>: 'Text " due to sum type")

# Documentation

type family HasSum (f :: Type -> Type) :: Bool where ... Source #

Equations

HasSum (V1 :: Type -> Type) = 'False |
HasSum (U1 :: Type -> Type) = 'False |
HasSum (K1 i c :: Type -> Type) = 'False |
HasSum (M1 i c f) = HasSum f |
HasSum (f :*: g) = HasSum f || HasSum g |
HasSum (f :+: g) = 'True |

class Assert (pred :: Bool) (msg :: ErrorMessage) Source #

#### Instances

Instances details

(TypeError msg :: ()) ~ '() => Assert 'False msg Source # |
Instance details Defined in Generic.Data.Internal.Error
Assert 'True msg Source # |
Instance details Defined in Generic.Data.Internal.Error

type AssertNoSum (constraint :: Type -> Constraint) a = Assert (Not (HasSum (Rep a))) (((('Text "Cannot derive " ':<>: 'ShowType constraint) ':<>: 'Text " instance for ") ':<>: 'ShowType a) ':<>: 'Text " due to sum type") Source #

    >>> :set -XDeriveGeneric -XDerivingVia
    >>> import Generic.Data (Generically(..))
    >>> :{
      data AB = A | B
        deriving stock Generic
        deriving Semigroup via Generically AB
    :}
    ...
        • Cannot derive Semigroup instance for AB due to sum type
        • When deriving the instance for (Semigroup AB)