on master help sign in
Use CPP to avoid errors with old GHC from TypeApplications in class instance
a445fbaTeo Camarasu
servant-server/src/Servant/Server/Internal.hs+11−2
@@ -1,5 +1,6 @@
1{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE CPP #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DeriveDataTypeable #-}
5{-# LANGUAGE DeriveDataTypeable #-}
5{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleContexts #-}
@@ -823,7 +824,11 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
823-------------------------------------------------------------------------------
824-------------------------------------------------------------------------------
824
825
825-- Erroring instance for 'HasServer' when a combinator is not fully applied
826-- Erroring instance for 'HasServer' when a combinator is not fully applied
827+instance TypeError (PartialApplication
828+#if __GLASGOW_HASKELL__ >= 904
829+ @(Type -> [Type] -> Constraint)
830+#endif
826−instance TypeError (PartialApplication @(Type -> [Type] -> Constraint) HasServer arr) => HasServer ((arr :: a -> b) :> sub) context
831+ HasServer arr) => HasServer ((arr :: a -> b) :> sub) context
827 where
832 where
828 type ServerT (arr :> sub) _ = TypeError (PartialApplication (HasServer :: * -> [*] -> Constraint) arr)
833 type ServerT (arr :> sub) _ = TypeError (PartialApplication (HasServer :: * -> [*] -> Constraint) arr)
829 route = error "unreachable"
834 route = error "unreachable"
@@ -867,7 +872,11 @@ type HasServerArrowTypeError a b =
867-- XXX: This omits the @context@ parameter, e.g.:
872-- XXX: This omits the @context@ parameter, e.g.:
868--
873--
869-- "There is no instance for HasServer (Bool :> …)". Do we care ?
874-- "There is no instance for HasServer (Bool :> …)". Do we care ?
870−instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub @(Type -> [Type] -> Constraint) HasServer ty) => HasServer (ty :> sub) context
875+instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub
876+#if __GLASGOW_HASKELL__ >= 904
877+ @(Type -> [Type] -> Constraint)
878+#endif
879+ HasServer ty) => HasServer (ty :> sub) context
871
880
872instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasServer api context)) => HasServer api context
881instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasServer api context)) => HasServer api context
873
882
servant/src/Servant/Links.hs+11−2
@@ -1,5 +1,6 @@
1{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE CPP #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE FlexibleInstances #-}
@@ -649,12 +650,20 @@ simpleToLink _ toA _ = toLink toA (Proxy :: Proxy sub)
649-- >>> import Data.Text (Text)
650-- >>> import Data.Text (Text)
650
651
651-- Erroring instance for 'HasLink' when a combinator is not fully applied
652-- Erroring instance for 'HasLink' when a combinator is not fully applied
652−instance TypeError (PartialApplication @(Type -> Constraint) HasLink arr) => HasLink ((arr :: a -> b) :> sub)
653+instance TypeError (PartialApplication
654+#if __GLASGOW_HASKELL__ >= 904
655+ @(Type -> Constraint)
656+#endif
657+ HasLink arr) => HasLink ((arr :: a -> b) :> sub)
653 where
658 where
654 type MkLink (arr :> sub) _ = TypeError (PartialApplication (HasLink :: * -> Constraint) arr)
659 type MkLink (arr :> sub) _ = TypeError (PartialApplication (HasLink :: * -> Constraint) arr)
655 toLink = error "unreachable"
660 toLink = error "unreachable"
656
661
657-- Erroring instances for 'HasLink' for unknown API combinators
662-- Erroring instances for 'HasLink' for unknown API combinators
658−instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub @(Type -> Constraint) HasLink ty) => HasLink (ty :> sub)
663+instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub
664+#if __GLASGOW_HASKELL__ >= 904
665+ @(Type -> Constraint)
666+#endif
667+ HasLink ty) => HasLink (ty :> sub)
659
668
660instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasLink api)) => HasLink api
669instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasLink api)) => HasLink api