Add EmptyForeignAPI and instance HasForeign ... EmptyAPI

This commit is contained in:
David Turner 2017-05-16 10:01:33 +00:00
parent 2cfa71891b
commit fa3f1869f2
2 changed files with 12 additions and 0 deletions

View File

@ -45,6 +45,7 @@ Now let's have the API type(s) and the accompanying datatypes.
``` haskell
type API = "point" :> Get '[JSON] Point
:<|> "books" :> QueryParam "q" Text :> Get '[JSON] (Search Book)
:<|> EmptyAPI
type API' = API :<|> Raw
@ -133,6 +134,7 @@ api' = Proxy
server :: Server API
server = randomPoint
:<|> searchBook
:<|> emptyAPIServer
server' :: Server API'
server' = server

View File

@ -187,6 +187,13 @@ instance (HasForeign lang ftype a, HasForeign lang ftype b)
foreignFor lang ftype (Proxy :: Proxy a) req
:<|> foreignFor lang ftype (Proxy :: Proxy b) req
data EmptyForeignAPI = EmptyForeignAPI
instance HasForeign lang ftype EmptyAPI where
type Foreign ftype EmptyAPI = EmptyForeignAPI
foreignFor Proxy Proxy Proxy _ = EmptyForeignAPI
instance (KnownSymbol sym, HasForeignType lang ftype t, HasForeign lang ftype api)
=> HasForeign lang ftype (Capture sym t :> api) where
type Foreign ftype (Capture sym t :> api) = Foreign ftype api
@ -349,6 +356,9 @@ instance HasForeign lang ftype api
class GenerateList ftype reqs where
generateList :: reqs -> [Req ftype]
instance GenerateList ftype EmptyForeignAPI where
generateList _ = []
instance GenerateList ftype (Req ftype) where
generateList r = [r]