Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RecordParam (a :: *)
- type family UnRecordParam (x :: *) :: * where ...
Documentation
data RecordParam (a :: *) Source #
RecordParam uses the fields in the record to represent the parameters. The name of the field is used as parameter name, and the type is the return type. For example, this api:
type API = "users" :> (QueryParam "category" Category :> QueryParam' '[Required, Strict] "sort_by" SortBy :> QueryFlag "with_schema" :> QueryParams "filters" Filter :> Get '[JSON] User
can be written with records:
data UserParams = UserParams { category :: Maybe Category , sort_by :: Sortby , with_schema :: Bool , filters :: [Filter] } type API = "users" :> RecordParam UserParams :> Get '[JSON] User
Instances
(Generic a, GHasLink (Rep a) sub) => HasLink (RecordParam a :> sub :: Type) Source # | |
Defined in Servant.Record type MkLink (RecordParam a :> sub) a # toLink :: (Link -> a0) -> Proxy (RecordParam a :> sub) -> Link -> MkLink (RecordParam a :> sub) a0 # | |
type MkLink (RecordParam a :> sub :: Type) b Source # | |
Defined in Servant.Record |
type family UnRecordParam (x :: *) :: * where ... Source #
Type family to rewrite a RecordParam Api to a regular servant API. Useful to define instances for classes that extract information from the API type, such as Servant.Swagger, or servant-foreign.
Typical use:
instance SomeClass (UnRecordParam (RecordParam a :> api))) => SomeClass (RecordParam a :> api) where someMethod _ = someMethod (Proxy :: Proxy (UnRecordParam (RecordParam a :> api))
UnRecordParam (a :> b) = ServantAppend (UnRecordParam a) b | |
UnRecordParam (RecordParam a) = UnRecordParam (Rep a ()) | |
UnRecordParam (D1 m c d) = UnRecordParam (c d) | |
UnRecordParam ((a :*: b) d) = ServantAppend (UnRecordParam (a d)) (UnRecordParam (b d)) | |
UnRecordParam (C1 m a d) = UnRecordParam (a d) | |
UnRecordParam (S1 ('MetaSel ('Just sym) d1 d2 d3) (Rec0 Bool) d) = QueryFlag sym | |
UnRecordParam (S1 ('MetaSel ('Just sym) d1 d2 d3) (Rec0 [a]) d) = QueryParams sym a | |
UnRecordParam (S1 ('MetaSel ('Just sym) d1 d2 d3) (Rec0 (Maybe a)) d) = QueryParam' [Optional, Strict] sym a | |
UnRecordParam (S1 ('MetaSel ('Just sym) d1 d2 d3) (Rec0 a) d) = QueryParam' [Required, Strict] sym a |