generic-data-asserts-0.2.0: Structural assertions on generic data representations.
Safe HaskellSafe-Inferred
LanguageGHC2021

Generic.Data.Rep.Assert

Description

Structural assertions on generic data representation.

Synopsis

Documentation

type family StripD1 a where ... Source #

Equations

StripD1 (D1 _ a) = a 

type GAssertNotVoid a = Assert (IsNotVoid (StripD1 (Rep a))) (GAssertErrorVoid a) Source #

Type is not void i.e. has at least one constructor.

type family IsNotVoid a where ... Source #

Equations

IsNotVoid V1 = False 
IsNotVoid _ = True 

type GAssertNotSum a = Assert (IsNotSum (StripD1 (Rep a))) (GAssertErrorSum a) Source #

Type is not a sum type i.e. has at most one constructor.

Permits void types.

type family IsNotSum a where ... Source #

Equations

IsNotSum (_ :+: _) = False 
IsNotSum _ = True 

type GAssertSum a = Assert (IsSum (StripD1 (Rep a))) (GAssertErrorNotSum a) Source #

Type is a sum type i.e. has >=2 constructors.

Permits void types.

type family IsSum a where ... Source #

Equations

IsSum (C1 _ _) = False 
IsSum _ = True 

type GAssertEnum a = Assert (IsEnum (StripD1 (Rep a))) (GAssertErrorNotEnum a) Source #

Type has only empty constructors.

Permits void types.

type family IsEnum a where ... Source #

Equations

IsEnum V1 = True 
IsEnum (C1 _ a) = ConsIsEmpty a 
IsEnum (l :+: r) = IsEnum l `And` IsEnum r 

type family ConsIsEmpty a where ... Source #

Equations

ConsIsEmpty U1 = True 
ConsIsEmpty _ = False 

type family And l r where ... Source #

Type level boolean AND.

Equations

And True True = True 
And _ _ = False