From b84095ee5a34097a35ac277fb84d750089c29aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Deest?= Date: Wed, 23 Mar 2022 12:49:58 +0100 Subject: [PATCH] Reformatting + clarification comment --- servant/src/Servant/API/ResponseHeaders.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servant/src/Servant/API/ResponseHeaders.hs b/servant/src/Servant/API/ResponseHeaders.hs index 556faa8c..16f72462 100644 --- a/servant/src/Servant/API/ResponseHeaders.hs +++ b/servant/src/Servant/API/ResponseHeaders.hs @@ -183,7 +183,11 @@ instance (AddHeader h v old new) => AddHeader h v (Union '[old]) (Union '[new]) SOP.Z $ SOP.I $ addOptionalHeader hdr $ SOP.unI $ SOP.unZ $ resp instance - (AddHeader h v old new, AddHeader h v (Union oldrest) (Union newrest), oldrest ~ (a ': as), newrest ~ (b ': bs)) + ( AddHeader h v old new, AddHeader h v (Union oldrest) (Union newrest) + -- This ensures that the remainder of the response list is _not_ empty + -- It is necessary to prevent the two instances for union types from + -- overlapping. + , oldrest ~ (a ': as), newrest ~ (b ': bs)) => AddHeader h v (Union (old ': (a ': as))) (Union (new ': (b ': bs))) where addOptionalHeader hdr resp = case resp of SOP.Z (SOP.I rHead) -> SOP.Z $ SOP.I $ addOptionalHeader hdr rHead