on master help sign in
Fix TypeError for GHC-9.4

In GHC-9.4 the typechecker changed requiring more annotations in positions like this. See https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.4#ambiguous-types-containing-a-typeerror and https://gitlab.haskell.org/ghc/ghc/-/issues/21149

commit4627683a647395f44443fa66d7e92a79eb98cab8 authorTeo Camarasu <teofilcamarasu@gmail.com> dateTue 9 Aug 2022, 11:05 (4 years ago) parente4650de
2 files changed+8−4
servant-server/src/Servant/Server/Internal.hs+4−2 servant/src/Servant/Links.hs+4−2
servant-server/src/Servant/Server/Internal.hs+4−2
@@ -94,6 +94,8 @@ import Servant.API.TypeErrors
9494import Web.HttpApiData
9595 (FromHttpApiData, parseHeader, parseQueryParam, parseUrlPiece,
9696 parseUrlPieces)
97+import Data.Kind
98+ (Type)
9799
98100import Servant.Server.Internal.BasicAuth
99101import Servant.Server.Internal.Context
@@ -821,7 +823,7 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
821823-------------------------------------------------------------------------------
822824
823825-- Erroring instance for 'HasServer' when a combinator is not fully applied
824−instance TypeError (PartialApplication HasServer arr) => HasServer ((arr :: a -> b) :> sub) context
826+instance TypeError (PartialApplication @(Type -> [Type] -> Constraint) HasServer arr) => HasServer ((arr :: a -> b) :> sub) context
825827 where
826828 type ServerT (arr :> sub) _ = TypeError (PartialApplication (HasServer :: * -> [*] -> Constraint) arr)
827829 route = error "unreachable"
@@ -865,7 +867,7 @@ type HasServerArrowTypeError a b =
865867-- XXX: This omits the @context@ parameter, e.g.:
866868--
867869-- "There is no instance for HasServer (Bool :> …)". Do we care ?
868−instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub HasServer ty) => HasServer (ty :> sub) context
870+instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub @(Type -> [Type] -> Constraint) HasServer ty) => HasServer (ty :> sub) context
869871
870872instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasServer api context)) => HasServer api context
871873
servant/src/Servant/Links.hs+4−2
@@ -193,6 +193,8 @@ import Servant.API.Verbs
193193import Servant.API.WithNamedContext
194194 (WithNamedContext)
195195import Web.HttpApiData
196+import Data.Kind
197+ (Type)
196198
197199-- | A safe link datatype.
198200-- The only way of constructing a 'Link' is using 'safeLink', which means any
@@ -647,12 +649,12 @@ simpleToLink _ toA _ = toLink toA (Proxy :: Proxy sub)
647649-- >>> import Data.Text (Text)
648650
649651-- Erroring instance for 'HasLink' when a combinator is not fully applied
650−instance TypeError (PartialApplication HasLink arr) => HasLink ((arr :: a -> b) :> sub)
652+instance TypeError (PartialApplication @(Type -> Constraint) HasLink arr) => HasLink ((arr :: a -> b) :> sub)
651653 where
652654 type MkLink (arr :> sub) _ = TypeError (PartialApplication (HasLink :: * -> Constraint) arr)
653655 toLink = error "unreachable"
654656
655657-- Erroring instances for 'HasLink' for unknown API combinators
656−instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub HasLink ty) => HasLink (ty :> sub)
658+instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub @(Type -> Constraint) HasLink ty) => HasLink (ty :> sub)
657659
658660instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasLink api)) => HasLink api