1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4module Servant.API.Union where
11-- | Union of two APIs, first takes precedence in case of overlap.
12data a :<|> b = a :<|> b
15instance (HasServer a, HasServer b) => HasServer (a :<|> b) where
16 type Server (a :<|> b) = Server a :<|> Server b
17 route Proxy (a :<|> b) request respond =
18 route pa a request $ \ mResponse ->
19 if isMismatch mResponse
20 then route pb b request $ \mResponse' -> respond (mResponse <> mResponse')
21 else respond mResponse
23 where pa = Proxy :: Proxy a
26instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
27 type Client (a :<|> b) = Client a :<|> Client b
28 clientWithRoute Proxy req =
29 clientWithRoute (Proxy :: Proxy a) req :<|>
30 clientWithRoute (Proxy :: Proxy b) req
32instance (HasDocs layout1, HasDocs layout2)
33 => HasDocs (layout1 :<|> layout2) where
35 docsFor Proxy (ep, action) = docsFor p1 (ep, action) <> docsFor p2 (ep, action)
37 where p1 :: Proxy layout1
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list