Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Mensam.API.Aeson.StaticText.Internal.Union
Description
This module is heavily inspired by servant's Servant.Api.Uverb.Union.
Synopsis
- type Union = NS I
- type IsMember (a :: u) (as :: [u]) = (Unique as, CheckElemIsMember a as, UElem a as)
- class UElem x xs where
- type family CheckElemIsMember (a :: k) (as :: [k]) :: Constraint where ...
- type NoElementError (r :: k) (rs :: [k]) = (('Text "Expected one of:" ':$$: ('Text " " ':<>: 'ShowType rs)) ':$$: 'Text "But got:") ':$$: ('Text " " ':<>: 'ShowType r)
- type DuplicateElementError (rs :: [k]) = 'Text "Duplicate element in list:" ':$$: ('Text " " ':<>: 'ShowType rs)
- type family Elem (x :: k) (xs :: [k]) :: Bool where ...
- type family Unique xs :: Constraint where ...
- type family Nubbed xs :: Bool where ...
- type family Map f xs where ...
Documentation
Stuff stolen from 'Data.WorldPeace" but for generics-sop
type family CheckElemIsMember (a :: k) (as :: [k]) :: Constraint where ... Source #
Check whether a
is in given type-level list.
This will throw a nice error if the element is not in the list.
Equations
CheckElemIsMember a as = If (Elem a as) (() :: Constraint) (TypeError (NoElementError a as)) |
type NoElementError (r :: k) (rs :: [k]) = (('Text "Expected one of:" ':$$: ('Text " " ':<>: 'ShowType rs)) ':$$: 'Text "But got:") ':$$: ('Text " " ':<>: 'ShowType r) Source #
type DuplicateElementError (rs :: [k]) = 'Text "Duplicate element in list:" ':$$: ('Text " " ':<>: 'ShowType rs) Source #
type family Unique xs :: Constraint where ... Source #
Check whether all values in a type-level list are distinct. This will throw a nice error if there are any duplicate elements in the list.
Equations
Unique xs = If (Nubbed xs == 'True) (() :: Constraint) (TypeError (DuplicateElementError xs)) |