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

Safe HaskellSafe



Error messages.


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.



type family HasSum f where ... Source #


HasSum V1 = False 
HasSum U1 = False 
HasSum (K1 i c) = 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 #

(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 :: * -> 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)