Copyright | © Jonathan Lorimer 2023 |
---|---|
License | MIT |
Maintainer | jonathanlorimer@pm.me |
Stability | stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides type level assertions so that we can constrain the instances user's can create, and give them good error messages
Since: 0.0.2.0
Synopsis
- class Assert (pred :: Bool) (msg :: ErrorMessage)
- type family IsTopLevelRecord f where ...
- type AssertTopLevelRecord (constraint :: Type -> Constraint) a = Assert (IsTopLevelRecord (Rep a)) (((('Text "\128683 Cannot derive " ':<>: 'ShowType constraint) ':<>: 'Text " instance for ") ':<>: 'ShowType a) ':$$: (('Text "\128161 " ':<>: 'ShowType constraint) ':<>: 'Text " must be derived on a top level record type with named fields."))
Documentation
class Assert (pred :: Bool) (msg :: ErrorMessage) Source #
A type level helper for creating custom error messages based on a predicate
Since: 0.0.2.0
type family IsTopLevelRecord f where ... Source #
A type level predicate that helps us identify top level product types
Since: 0.0.2.0
IsTopLevelRecord V1 = 'False | |
IsTopLevelRecord U1 = 'False | |
IsTopLevelRecord (K1 i c) = 'False | |
IsTopLevelRecord (M1 D c f) = IsTopLevelRecord f | |
IsTopLevelRecord (M1 C c f) = IsTopLevelRecord f | |
IsTopLevelRecord (M1 S c f) = 'True | |
IsTopLevelRecord (f :*: g) = IsTopLevelRecord f | |
IsTopLevelRecord (f :+: g) = 'False |
type AssertTopLevelRecord (constraint :: Type -> Constraint) a = Assert (IsTopLevelRecord (Rep a)) (((('Text "\128683 Cannot derive " ':<>: 'ShowType constraint) ':<>: 'Text " instance for ") ':<>: 'ShowType a) ':$$: (('Text "\128161 " ':<>: 'ShowType constraint) ':<>: 'Text " must be derived on a top level record type with named fields.")) Source #
A custom error message for non-top-level records
Since: 0.0.2.0