@@ -42,7 +42,7 @@ import qualified Data.ByteString as B
4242import qualified Data.ByteString.Builder as BB
4343import qualified Data.ByteString.Char8 as BC8
4444import qualified Data.ByteString.Lazy as BL
45- import Data.Constraint (Constraint , Dict (.. ))
45+ import Data.Constraint (Dict (.. ))
4646import Data.Either
4747 (partitionEithers )
4848import Data.Maybe
@@ -57,7 +57,7 @@ import qualified Data.Text as T
5757import Data.Typeable
5858import GHC.Generics
5959import GHC.TypeLits
60- (KnownNat , KnownSymbol , TypeError , symbolVal )
60+ (KnownNat , KnownSymbol , symbolVal )
6161import qualified Network.HTTP.Media as NHM
6262import Network.HTTP.Types hiding
6363 (Header , ResponseHeaders )
@@ -91,7 +91,6 @@ import Servant.API.ResponseHeaders
9191import Servant.API.Status
9292 (statusFromNat )
9393import qualified Servant.Types.SourceT as S
94- import Servant.API.TypeErrors
9594import Web.HttpApiData
9695 (FromHttpApiData , parseHeader , parseQueryParam , parseUrlPiece ,
9796 parseUrlPieces )
@@ -107,8 +106,6 @@ import Servant.Server.Internal.RouteResult
107106import Servant.Server.Internal.RoutingApplication
108107import Servant.Server.Internal.ServerError
109108
110- import GHC.TypeLits
111- (ErrorMessage (.. ))
112109import Servant.API.TypeLevel
113110 (AtLeastOneFragment , FragmentUnique )
114111
@@ -817,67 +814,6 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
817814
818815 hoistServerWithContext _ _ nt s = hoistServerWithContext (Proxy :: Proxy subApi ) (Proxy :: Proxy subContext ) nt s
819816
820- -------------------------------------------------------------------------------
821- -- Custom type errors
822- -------------------------------------------------------------------------------
823-
824- -- Erroring instance for 'HasServer' when a combinator is not fully applied
825- instance TypeError (PartialApplication
826- #if __GLASGOW_HASKELL__ >= 904
827- @ (Type -> [Type ] -> Constraint )
828- #endif
829- HasServer arr) => HasServer ((arr :: a -> b ) :> sub) context
830- where
831- type ServerT (arr :> sub ) _ = TypeError (PartialApplication (HasServer :: * -> [* ] -> Constraint ) arr )
832- route = error " unreachable"
833- hoistServerWithContext _ _ _ _ = error " unreachable"
834-
835- -- | This instance prevents from accidentally using '->' instead of ':>'
836- --
837- -- >>> serve (Proxy :: Proxy (Capture "foo" Int -> Get '[JSON] Int)) (error "...")
838- -- ...
839- -- ...No instance HasServer (a -> b).
840- -- ...Maybe you have used '->' instead of ':>' between
841- -- ...Capture' '[] "foo" Int
842- -- ...and
843- -- ...Verb 'GET 200 '[JSON] Int
844- -- ...
845- --
846- -- >>> undefined :: Server (Capture "foo" Int -> Get '[JSON] Int)
847- -- ...
848- -- ...No instance HasServer (a -> b).
849- -- ...Maybe you have used '->' instead of ':>' between
850- -- ...Capture' '[] "foo" Int
851- -- ...and
852- -- ...Verb 'GET 200 '[JSON] Int
853- -- ...
854- --
855- instance TypeError (HasServerArrowTypeError a b ) => HasServer (a -> b ) context
856- where
857- type ServerT (a -> b ) m = TypeError (HasServerArrowTypeError a b )
858- route _ _ _ = error " servant-server panic: impossible happened in HasServer (a -> b)"
859- hoistServerWithContext _ _ _ = id
860-
861- type HasServerArrowTypeError a b =
862- 'Text " No instance HasServer (a -> b)."
863- ':$$: 'Text " Maybe you have used '->' instead of ':>' between "
864- ':$$: 'ShowType a
865- ':$$: 'Text " and"
866- ':$$: 'ShowType b
867-
868- -- Erroring instances for 'HasServer' for unknown API combinators
869-
870- -- XXX: This omits the @context@ parameter, e.g.:
871- --
872- -- "There is no instance for HasServer (Bool :> …)". Do we care ?
873- instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub
874- #if __GLASGOW_HASKELL__ >= 904
875- @ (Type -> [Type ] -> Constraint )
876- #endif
877- HasServer ty) => HasServer (ty :> sub) context
878-
879- instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasServer api context )) => HasServer api context
880-
881817-- | Ignore @'Fragment'@ in server handlers.
882818-- See <https://ietf.org/rfc/rfc2616.html#section-15.1.3> for more details.
883819--
0 commit comments