{-# LANGUAGE
PolyKinds
, TypeFamilies
, TypeOperators
, ConstraintKinds
#-}
module Generics.Constraints (Constraints) where
import Data.Kind (Constraint, Type)
import GHC.Generics
type family Constraints' (t :: Type -> Type) (c :: Type -> Constraint) :: Constraint
type instance Constraints' V1 c = ()
type instance Constraints' U1 c = ()
type instance Constraints' (f :+: g) c = (Constraints' f c, Constraints' g c)
type instance Constraints' (f :*: g) c = (Constraints' f c, Constraints' g c)
type instance Constraints' (f :.: g) c = Constraints' g c
type instance Constraints' Par1 c = ()
type instance Constraints' (Rec1 f) c = ()
type instance Constraints' (K1 i a) c = c a
type instance Constraints' (M1 i t f) c = Constraints' f c
type Constraints t c = Constraints' (Rep t) c