servant-generic-0.1.0.2: Specify Servant APIs with records.

Safe HaskellNone
LanguageHaskell2010

Servant.Generic

Contents

Synopsis

Documentation

type family mode :- api infixl 3 Source #

A type family that applies an appropriate type family to the api parameter. For example, passing AsApi will leave api untouched, while AsServerT m will produce ServerT api m.

Instances

type AsLink :- api Source # 
type AsLink :- api = MkLink * api Link
type AsApi :- api Source # 
type AsApi :- api = api
type (AsServerT m) :- api Source # 
type (AsServerT m) :- api = ServerT * api m

data AsServerT (m :: * -> *) Source #

A type that specifies that an API record contains a server implementation.

Instances

type (AsServerT m) :- api Source # 
type (AsServerT m) :- api = ServerT * api m

data AsApi Source #

A type that specifies that an API record contains an API definition. Only useful at type-level.

Instances

type AsApi :- api Source # 
type AsApi :- api = api

data AsLink Source #

A type that specifies that an API record contains a set of links.

(Useful since servant 0.12)

type ToServant a = GToServant (Rep a) Source #

Turns a generic product type into a linear tree of :<|> combinators. For example, given

  data Foo route = Foo
    { foo :: route :-
        Get '[PlainText] Text
    , bar :: route :-
        Get '[PlainText] Text
    }
 ToServant (Foo AsApi) ~ Get '[PlainText] Text :<|> Get '[PlainText] Text

toServant :: GenericProduct a => a -> ToServant a Source #

See ToServant, but at value-level.

fromServant :: GenericProduct a => ToServant a -> a Source #

Inverse of toServant.

This can be used to turn generated values such as client functions into records.

You may need to provide a type signature for the output type (your record type).

Internals

class GProduct f where Source #

A class of generic product types.

Minimal complete definition

gtoServant, gfromServant

Associated Types

type GToServant f Source #

Instances

GProduct (K1 * i c) Source # 

Associated Types

type GToServant (K1 * i c :: * -> *) :: * Source #

Methods

gtoServant :: K1 * i c p -> GToServant (K1 * i c) Source #

gfromServant :: GToServant (K1 * i c) -> K1 * i c p Source #

(GProduct l, GProduct r) => GProduct ((:*:) * l r) Source # 

Associated Types

type GToServant ((* :*: l) r :: * -> *) :: * Source #

Methods

gtoServant :: (* :*: l) r p -> GToServant ((* :*: l) r) Source #

gfromServant :: GToServant ((* :*: l) r) -> (* :*: l) r p Source #

GProduct f => GProduct (M1 * i c f) Source # 

Associated Types

type GToServant (M1 * i c f :: * -> *) :: * Source #

Methods

gtoServant :: M1 * i c f p -> GToServant (M1 * i c f) Source #

gfromServant :: GToServant (M1 * i c f) -> M1 * i c f p Source #

class Generic a where #

Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.

Minimal complete definition

from, to

Associated Types

type Rep a :: * -> * #

Generic representation type

Methods

from :: a -> Rep a x #

Convert from the datatype to its representation

to :: Rep a x -> a #

Convert from the representation to the datatype

Instances

Generic Bool 

Associated Types

type Rep Bool :: * -> * #

Methods

from :: Bool -> Rep Bool x #

to :: Rep Bool x -> Bool #

Generic Ordering 

Associated Types

type Rep Ordering :: * -> * #

Methods

from :: Ordering -> Rep Ordering x #

to :: Rep Ordering x -> Ordering #

Generic () 

Associated Types

type Rep () :: * -> * #

Methods

from :: () -> Rep () x #

to :: Rep () x -> () #

Generic Fixity 

Associated Types

type Rep Fixity :: * -> * #

Methods

from :: Fixity -> Rep Fixity x #

to :: Rep Fixity x -> Fixity #

Generic Associativity 

Associated Types

type Rep Associativity :: * -> * #

Generic SourceUnpackedness 
Generic SourceStrictness 
Generic DecidedStrictness 
Generic [a] 

Associated Types

type Rep [a] :: * -> * #

Methods

from :: [a] -> Rep [a] x #

to :: Rep [a] x -> [a] #

Generic (Maybe a) 

Associated Types

type Rep (Maybe a) :: * -> * #

Methods

from :: Maybe a -> Rep (Maybe a) x #

to :: Rep (Maybe a) x -> Maybe a #

Generic (Par1 p) 

Associated Types

type Rep (Par1 p) :: * -> * #

Methods

from :: Par1 p -> Rep (Par1 p) x #

to :: Rep (Par1 p) x -> Par1 p #

Generic (Handler a) 

Associated Types

type Rep (Handler a) :: * -> * #

Methods

from :: Handler a -> Rep (Handler a) x #

to :: Rep (Handler a) x -> Handler a #

Generic (Either a b) 

Associated Types

type Rep (Either a b) :: * -> * #

Methods

from :: Either a b -> Rep (Either a b) x #

to :: Rep (Either a b) x -> Either a b #

Generic (V1 k p) 

Associated Types

type Rep (V1 k p) :: * -> * #

Methods

from :: V1 k p -> Rep (V1 k p) x #

to :: Rep (V1 k p) x -> V1 k p #

Generic (U1 k p) 

Associated Types

type Rep (U1 k p) :: * -> * #

Methods

from :: U1 k p -> Rep (U1 k p) x #

to :: Rep (U1 k p) x -> U1 k p #

Generic (a, b) 

Associated Types

type Rep (a, b) :: * -> * #

Methods

from :: (a, b) -> Rep (a, b) x #

to :: Rep (a, b) x -> (a, b) #

Generic (Proxy k t) 

Associated Types

type Rep (Proxy k t) :: * -> * #

Methods

from :: Proxy k t -> Rep (Proxy k t) x #

to :: Rep (Proxy k t) x -> Proxy k t #

Generic (Rec1 k f p) 

Associated Types

type Rep (Rec1 k f p) :: * -> * #

Methods

from :: Rec1 k f p -> Rep (Rec1 k f p) x #

to :: Rep (Rec1 k f p) x -> Rec1 k f p #

Generic (URec k (Ptr ()) p) 

Associated Types

type Rep (URec k (Ptr ()) p) :: * -> * #

Methods

from :: URec k (Ptr ()) p -> Rep (URec k (Ptr ()) p) x #

to :: Rep (URec k (Ptr ()) p) x -> URec k (Ptr ()) p #

Generic (URec k Char p) 

Associated Types

type Rep (URec k Char p) :: * -> * #

Methods

from :: URec k Char p -> Rep (URec k Char p) x #

to :: Rep (URec k Char p) x -> URec k Char p #

Generic (URec k Double p) 

Associated Types

type Rep (URec k Double p) :: * -> * #

Methods

from :: URec k Double p -> Rep (URec k Double p) x #

to :: Rep (URec k Double p) x -> URec k Double p #

Generic (URec k Float p) 

Associated Types

type Rep (URec k Float p) :: * -> * #

Methods

from :: URec k Float p -> Rep (URec k Float p) x #

to :: Rep (URec k Float p) x -> URec k Float p #

Generic (URec k Int p) 

Associated Types

type Rep (URec k Int p) :: * -> * #

Methods

from :: URec k Int p -> Rep (URec k Int p) x #

to :: Rep (URec k Int p) x -> URec k Int p #

Generic (URec k Word p) 

Associated Types

type Rep (URec k Word p) :: * -> * #

Methods

from :: URec k Word p -> Rep (URec k Word p) x #

to :: Rep (URec k Word p) x -> URec k Word p #

Generic (a, b, c) 

Associated Types

type Rep (a, b, c) :: * -> * #

Methods

from :: (a, b, c) -> Rep (a, b, c) x #

to :: Rep (a, b, c) x -> (a, b, c) #

Generic (K1 k i c p) 

Associated Types

type Rep (K1 k i c p) :: * -> * #

Methods

from :: K1 k i c p -> Rep (K1 k i c p) x #

to :: Rep (K1 k i c p) x -> K1 k i c p #

Generic ((:+:) k f g p) 

Associated Types

type Rep ((k :+: f) g p) :: * -> * #

Methods

from :: (k :+: f) g p -> Rep ((k :+: f) g p) x #

to :: Rep ((k :+: f) g p) x -> (k :+: f) g p #

Generic ((:*:) k f g p) 

Associated Types

type Rep ((k :*: f) g p) :: * -> * #

Methods

from :: (k :*: f) g p -> Rep ((k :*: f) g p) x #

to :: Rep ((k :*: f) g p) x -> (k :*: f) g p #

Generic (a, b, c, d) 

Associated Types

type Rep (a, b, c, d) :: * -> * #

Methods

from :: (a, b, c, d) -> Rep (a, b, c, d) x #

to :: Rep (a, b, c, d) x -> (a, b, c, d) #

Generic (M1 k i c f p) 

Associated Types

type Rep (M1 k i c f p) :: * -> * #

Methods

from :: M1 k i c f p -> Rep (M1 k i c f p) x #

to :: Rep (M1 k i c f p) x -> M1 k i c f p #

Generic ((:.:) k2 k1 f g p) 

Associated Types

type Rep ((k2 :.: k1) f g p) :: * -> * #

Methods

from :: (k2 :.: k1) f g p -> Rep ((k2 :.: k1) f g p) x #

to :: Rep ((k2 :.: k1) f g p) x -> (k2 :.: k1) f g p #

Generic (a, b, c, d, e) 

Associated Types

type Rep (a, b, c, d, e) :: * -> * #

Methods

from :: (a, b, c, d, e) -> Rep (a, b, c, d, e) x #

to :: Rep (a, b, c, d, e) x -> (a, b, c, d, e) #

Generic (Verb k1 method statusCode contentTypes a) 

Associated Types

type Rep (Verb k1 method statusCode contentTypes a) :: * -> * #

Methods

from :: Verb k1 method statusCode contentTypes a -> Rep (Verb k1 method statusCode contentTypes a) x #

to :: Rep (Verb k1 method statusCode contentTypes a) x -> Verb k1 method statusCode contentTypes a #

Generic (a, b, c, d, e, f) 

Associated Types

type Rep (a, b, c, d, e, f) :: * -> * #

Methods

from :: (a, b, c, d, e, f) -> Rep (a, b, c, d, e, f) x #

to :: Rep (a, b, c, d, e, f) x -> (a, b, c, d, e, f) #

Generic (a, b, c, d, e, f, g) 

Associated Types

type Rep (a, b, c, d, e, f, g) :: * -> * #

Methods

from :: (a, b, c, d, e, f, g) -> Rep (a, b, c, d, e, f, g) x #

to :: Rep (a, b, c, d, e, f, g) x -> (a, b, c, d, e, f, g) #

fieldLink :: forall routes endpoint. (IsElem endpoint (ToServant (routes AsApi)), HasLink endpoint) => (routes AsApi -> endpoint) -> MkLink endpoint Link Source #

Given an API record field, create a link for that route. Only the field's type is used.