Skip to content

Commit 4627683

Browse files
committed
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
1 parent e4650de commit 4627683

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

servant-server/src/Servant/Server/Internal.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ import Servant.API.TypeErrors
9494
import Web.HttpApiData
9595
(FromHttpApiData, parseHeader, parseQueryParam, parseUrlPiece,
9696
parseUrlPieces)
97+
import Data.Kind
98+
(Type)
9799

98100
import Servant.Server.Internal.BasicAuth
99101
import 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

870872
instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasServer api context)) => HasServer api context
871873

servant/src/Servant/Links.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ import Servant.API.Verbs
193193
import Servant.API.WithNamedContext
194194
(WithNamedContext)
195195
import 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

658660
instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasLink api)) => HasLink api

0 commit comments

Comments
 (0)