servant-validate-0.1.0.0: Chekc static properties of servant APIs
Copyright(c) Justin Le 2021
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Servant.Validate.Internal

Description

Internal type-level tools.

Documentation

data ApiTree Source #

Constructors

Branch [Symbol] [(Symbol, ApiTree)] 

type family Compare (a :: k) (b :: k) :: Ordering Source #

Instances

Instances details
type Compare (a :: Symbol) (b :: Symbol) Source # 
Instance details

Defined in Servant.Validate.Internal

type Compare (a :: Symbol) (b :: Symbol) = CmpSymbol a b

type family Cases (c :: Ordering) (lt :: k) (eq :: k) (gt :: k) where ... Source #

Equations

Cases 'LT lt eq gt = lt 
Cases 'EQ lt eq gt = eq 
Cases 'GT lt eq gt = gt 

type family MergeMethods err (xs :: [k]) (ys :: [k]) :: [k] where ... Source #

Equations

MergeMethods err '[] '[] = '[] 
MergeMethods err '[] (y ': ys) = y ': ys 
MergeMethods err (x ': xs) '[] = x ': xs 
MergeMethods err (x ': xs) (y ': ys) = Cases (Compare x y) (x ': MergeMethods err xs (y ': ys)) (TypeError ((err :<>: 'Text ": ") :<>: ShowType x)) (y ': MergeMethods err (x ': xs) ys) 

type family MergePaths (base :: [Symbol]) (xs :: [(Symbol, ApiTree)]) (ys :: [(Symbol, ApiTree)]) :: [(Symbol, ApiTree)] where ... Source #

Equations

MergePaths base '[] '[] = '[] 
MergePaths base '[] ('(b, y) ': bys) = '(b, y) ': bys 
MergePaths base ('(a, x) ': axs) '[] = '(a, x) ': axs 
MergePaths base ('(a, x) ': axs) ('(b, y) ': bys) = Cases (Compare a b) ('(a, x) ': MergePaths base axs ('(b, y) ': bys)) ('(a, MergeTree (a ': base) x y) ': MergePaths base axs bys) ('(b, y) ': MergePaths base ('(a, x) ': axs) bys) 

type family MergeTree (base :: [Symbol]) (a :: ApiTree) (b :: ApiTree) :: ApiTree where ... Source #

Equations

MergeTree base ('Branch mA pA) ('Branch mB pB) = 'Branch (MergeMethods ('Text "Duplicate method in API at path " :<>: 'Text ("/" `AppendSymbol` ShowPath base)) mA mB) (MergePaths base pA pB) 

compSym :: forall a b. SSym a -> SSym b -> SOrdering (CmpSymbol a b) Source #

sMergeMethods :: forall err xs ys. Prod SSym xs -> Prod SSym ys -> Prod SSym (MergeMethods err xs ys) Source #

sMergePaths :: forall base xs ys. Prod (Tup SSym SApiTree) xs -> Prod (Tup SSym SApiTree) ys -> Prod (Tup SSym SApiTree) (MergePaths base xs ys) Source #

sMergeTree :: forall base a b. SApiTree a -> SApiTree b -> SApiTree (MergeTree base a b) Source #

data SApiTree :: ApiTree -> Type where Source #

Constructors

SBranch :: Prod SSym ms -> Prod (Tup SSym SApiTree) ts -> SApiTree ('Branch ms ts) 

Instances

Instances details
Show (SApiTree api) Source # 
Instance details

Defined in Servant.Validate.Internal

Methods

showsPrec :: Int -> SApiTree api -> ShowS #

show :: SApiTree api -> String #

showList :: [SApiTree api] -> ShowS #

data Prod :: (k -> Type) -> [k] -> Type where Source #

Constructors

PNil :: Prod f '[] 
(:<) :: f a -> Prod f as -> Prod f (a ': as) infixr 5 

Instances

Instances details
(forall (a :: k). Show (f a)) => Show (Prod f as) Source # 
Instance details

Defined in Servant.Validate.Internal

Methods

showsPrec :: Int -> Prod f as -> ShowS #

show :: Prod f as -> String #

showList :: [Prod f as] -> ShowS #

data Tup :: (a -> Type) -> (b -> Type) -> (a, b) -> Type where Source #

Constructors

Tup :: f x -> g y -> Tup f g '(x, y) 

Instances

Instances details
(forall (a1 :: a). Show (f a1), forall (a1 :: b). Show (g a1)) => Show (Tup f g xy) Source # 
Instance details

Defined in Servant.Validate.Internal

Methods

showsPrec :: Int -> Tup f g xy -> ShowS #

show :: Tup f g xy -> String #

showList :: [Tup f g xy] -> ShowS #

data SSym :: Symbol -> Type where Source #

Constructors

SSym :: KnownSymbol s => SSym s 

Instances

Instances details
Show (SSym s) Source # 
Instance details

Defined in Servant.Validate.Internal

Methods

showsPrec :: Int -> SSym s -> ShowS #

show :: SSym s -> String #

showList :: [SSym s] -> ShowS #

toProd :: forall k (as :: [k]) f. (forall (a :: k). TypeRep a -> f a) -> TypeRep as -> Prod f as Source #

reflectProd :: forall k (as :: [k]) f r. (forall (a :: k). f a -> r) -> Prod f as -> [r] Source #

toTup :: (forall x. TypeRep x -> f x) -> (forall x. TypeRep x -> g x) -> TypeRep xy -> Tup f g xy Source #

reflectTup :: forall j k (xy :: (j, k)) f g a b. (forall (x :: j). f x -> a) -> (forall (y :: k). g y -> b) -> Tup f g xy -> (a, b) Source #

reflectSSym :: forall s. SSym s -> Text Source #