@@ -42,7 +42,7 @@ import qualified Data.ByteString as B
42
42
import qualified Data.ByteString.Builder as BB
43
43
import qualified Data.ByteString.Char8 as BC8
44
44
import qualified Data.ByteString.Lazy as BL
45
- import Data.Constraint (Constraint , Dict (.. ))
45
+ import Data.Constraint (Dict (.. ))
46
46
import Data.Either
47
47
(partitionEithers )
48
48
import Data.Maybe
@@ -57,7 +57,7 @@ import qualified Data.Text as T
57
57
import Data.Typeable
58
58
import GHC.Generics
59
59
import GHC.TypeLits
60
- (KnownNat , KnownSymbol , TypeError , symbolVal )
60
+ (KnownNat , KnownSymbol , symbolVal )
61
61
import qualified Network.HTTP.Media as NHM
62
62
import Network.HTTP.Types hiding
63
63
(Header , ResponseHeaders )
@@ -91,7 +91,6 @@ import Servant.API.ResponseHeaders
91
91
import Servant.API.Status
92
92
(statusFromNat )
93
93
import qualified Servant.Types.SourceT as S
94
- import Servant.API.TypeErrors
95
94
import Web.HttpApiData
96
95
(FromHttpApiData , parseHeader , parseQueryParam , parseUrlPiece ,
97
96
parseUrlPieces )
@@ -107,8 +106,6 @@ import Servant.Server.Internal.RouteResult
107
106
import Servant.Server.Internal.RoutingApplication
108
107
import Servant.Server.Internal.ServerError
109
108
110
- import GHC.TypeLits
111
- (ErrorMessage (.. ))
112
109
import Servant.API.TypeLevel
113
110
(AtLeastOneFragment , FragmentUnique )
114
111
@@ -817,67 +814,6 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
817
814
818
815
hoistServerWithContext _ _ nt s = hoistServerWithContext (Proxy :: Proxy subApi ) (Proxy :: Proxy subContext ) nt s
819
816
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
-
881
817
-- | Ignore @'Fragment'@ in server handlers.
882
818
-- See <https://ietf.org/rfc/rfc2616.html#section-15.1.3> for more details.
883
819
--
0 commit comments