Canonicalize the API type to make sure that the following 'law' holds: Server (a :> (b :<|> c)) ~ Server (a :> b) :<|> Server (a :> c)

This commit is contained in:
Alp Mestanogullari 2015-03-09 15:16:38 +01:00
parent bd9d476679
commit 837099d12d

View File

@ -165,7 +165,6 @@ class HasServer layout where
type Server' layout = ServerT layout (EitherT (Int, String) IO)
-- * Instances
-- | A server for @a ':<|>' b@ first tries to match the request against the route
@ -184,7 +183,7 @@ instance (HasServer a, HasServer b) => HasServer (a :<|> b) where
type ServerT (a :<|> b) m = ServerT a m :<|> ServerT b m
route Proxy (a :<|> b) request respond =
route pa a request $ \ mResponse ->
route pa a request $ \mResponse ->
if isMismatch mResponse
then route pb b request $ \mResponse' -> respond (mResponse <> mResponse')
else respond mResponse