@@ -794,6 +794,26 @@ type family NullPG (hask :: Type) :: NullityType where
794794 NullPG (Maybe hask) = 'Null (PG hask)
795795 NullPG hask = 'NotNull (PG hask)
796796
797+type family ParamsOf (hask :: Type) :: [NullityType] where
798+ ParamsOf hask = NullPGs (TupleCodeOf hask (Code hask))
799+
800+type family NullPGs (tuple :: [Type]) :: [NullityType] where
801+ NullPGs '[] = '[]
802+ NullPGs (hask ': tuple) = NullPG hask ': NullPGs tuple
803+
804+type family TupleCodeOf (hask :: Type) (code :: [[Type]]) :: [Type] where
805+ TupleCodeOf hask '[tuple] = tuple
806+ TupleCodeOf hask '[] =
807+ TypeError
808+ ( 'Text "The type `" :<>: 'ShowType hask :<>: 'Text "' is not a tuple type."
809+ :$$: 'Text "It is a void type with no constructors."
810+ )
811+ TupleCodeOf hask (_ ': _ ': _) =
812+ TypeError
813+ ( 'Text "The type `" :<>: 'ShowType hask :<>: 'Text "' is not a tuple type."
814+ :$$: 'Text "It is a sum type with more than one constructor."
815+ )
816+
797817-- | Calculates constructors of a datatype.
798818type family ConstructorsOf (datatype :: Type.DatatypeInfo)
799819 :: [Type.ConstructorInfo] where