module Servant.API.Routes.Header
( HeaderRep
, GetHeaderReps (..)
, mkHeaderRep
)
where
import Data.Kind (Type)
import Data.Typeable
import GHC.TypeLits
import Servant.API
import "this" Servant.API.Routes.Internal.Header
import "this" Servant.API.Routes.Utils
mkHeaderRep ::
forall sym a.
(KnownSymbol sym, Typeable a) =>
HeaderRep
=
HeaderRep
{ _hName :: Text
_hName = forall (name :: Symbol). KnownSymbol name => Text
knownSymbolT @sym
, _hType :: TypeRep
_hType = forall a. Typeable a => TypeRep
typeRepOf @a
}
class (hs :: [Type]) where
:: [HeaderRep]
instance GetHeaderReps '[] where
getHeaderReps :: [HeaderRep]
getHeaderReps = []
instance
(GetHeaderReps rest, KnownSymbol h, Typeable v) =>
GetHeaderReps (Header h v ': rest)
where
getHeaderReps :: [HeaderRep]
getHeaderReps = HeaderRep
header forall a. a -> [a] -> [a]
: forall (hs :: [*]). GetHeaderReps hs => [HeaderRep]
getHeaderReps @rest
where
header :: HeaderRep
header = forall (sym :: Symbol) a.
(KnownSymbol sym, Typeable a) =>
HeaderRep
mkHeaderRep @h @v