diff --git a/doc/tutorial/Javascript.lhs b/doc/tutorial/Javascript.lhs index 6a7aa6bb..8187d2c2 100644 --- a/doc/tutorial/Javascript.lhs +++ b/doc/tutorial/Javascript.lhs @@ -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 diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index ac68631c..fd12befd 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -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]