@@ -1,12 +1,15 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE OverlappingInstances #-}
55{-# LANGUAGE OverloadedStrings #-}
66{-# LANGUAGE PolyKinds #-}
77{-# LANGUAGE ScopedTypeVariables #-}
88{-# LANGUAGE TypeFamilies #-}
99{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
11+{-# LANGUAGE OverlappingInstances #-}
12+#endif
1013module Servant.Server.Internal where
1114
1215import Control.Applicative ((<$>))
@@ -280,8 +283,11 @@ instance HasServer Delete where
280283-- (returning a status code of 200). If there was no @Accept@ header or it
281284-- was @*/*@, we return encode using the first @Content-Type@ type on the
282285-- list.
283−instance ( AllCTRender ctypes a
284− ) => HasServer (Get ctypes a) where
286+instance
287+#if MIN_VERSION_base(4,8,0)
288+ {-# OVERLAPPABLE #-}
289+#endif
290+ ( AllCTRender ctypes a ) => HasServer (Get ctypes a) where
285291
286292 type ServerT' (Get ctypes a) m = m a
287293
@@ -302,8 +308,14 @@ instance ( AllCTRender ctypes a
302308 | otherwise = respond $ failWith NotFound
303309
304310-- '()' ==> 204 No Content
305−instance HasServer (Get ctypes ()) where
311+instance
312+#if MIN_VERSION_base(4,8,0)
313+ {-# OVERLAPPING #-}
314+#endif
315+ HasServer (Get ctypes ()) where
316+
306317 type ServerT' (Get ctypes ()) m = m ()
318+
307319 route Proxy action request respond
308320 | pathIsEmpty request && requestMethod request == methodGet = do
309321 e <- runEitherT action
@@ -316,8 +328,14 @@ instance HasServer (Get ctypes ()) where
316328 | otherwise = respond $ failWith NotFound
317329
318330-- Add response headers
319−instance ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
331+instance
332+#if MIN_VERSION_base(4,8,0)
333+ {-# OVERLAPPING #-}
334+#endif
335+ ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
336+
320337 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
338+
321339 route Proxy action request respond
322340 | pathIsEmpty request && requestMethod request == methodGet = do
323341 e <- runEitherT action
@@ -380,7 +398,11 @@ instance (KnownSymbol sym, FromText a, HasServer sublayout)
380398-- (returning a status code of 201). If there was no @Accept@ header or it
381399-- was @*/*@, we return encode using the first @Content-Type@ type on the
382400-- list.
383−instance ( AllCTRender ctypes a
401+instance
402+#if MIN_VERSION_base(4,8,0)
403+ {-# OVERLAPPABLE #-}
404+#endif
405+ ( AllCTRender ctypes a
384406 ) => HasServer (Post ctypes a) where
385407
386408 type ServerT' (Post ctypes a) m = m a
@@ -401,8 +423,14 @@ instance ( AllCTRender ctypes a
401423 respond $ failWith WrongMethod
402424 | otherwise = respond $ failWith NotFound
403425
404−instance HasServer (Post ctypes ()) where
426+instance
427+#if MIN_VERSION_base(4,8,0)
428+ {-# OVERLAPPING #-}
429+#endif
430+ HasServer (Post ctypes ()) where
431+
405432 type ServerT' (Post ctypes ()) m = m ()
433+
406434 route Proxy action request respond
407435 | pathIsEmpty request && requestMethod request == methodPost = do
408436 e <- runEitherT action
@@ -415,8 +443,14 @@ instance HasServer (Post ctypes ()) where
415443 | otherwise = respond $ failWith NotFound
416444
417445-- Add response headers
418−instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
446+instance
447+#if MIN_VERSION_base(4,8,0)
448+ {-# OVERLAPPING #-}
449+#endif
450+ ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
451+
419452 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
453+
420454 route Proxy action request respond
421455 | pathIsEmpty request && requestMethod request == methodPost = do
422456 e <- runEitherT action
@@ -447,8 +481,11 @@ instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
447481-- (returning a status code of 200). If there was no @Accept@ header or it
448482-- was @*/*@, we return encode using the first @Content-Type@ type on the
449483-- list.
450−instance ( AllCTRender ctypes a
451− ) => HasServer (Put ctypes a) where
484+instance
485+#if MIN_VERSION_base(4,8,0)
486+ {-# OVERLAPPABLE #-}
487+#endif
488+ ( AllCTRender ctypes a) => HasServer (Put ctypes a) where
452489
453490 type ServerT' (Put ctypes a) m = m a
454491
@@ -468,8 +505,14 @@ instance ( AllCTRender ctypes a
468505 respond $ failWith WrongMethod
469506 | otherwise = respond $ failWith NotFound
470507
471−instance HasServer (Put ctypes ()) where
508+instance
509+#if MIN_VERSION_base(4,8,0)
510+ {-# OVERLAPPING #-}
511+#endif
512+ HasServer (Put ctypes ()) where
513+
472514 type ServerT' (Put ctypes ()) m = m ()
515+
473516 route Proxy action request respond
474517 | pathIsEmpty request && requestMethod request == methodPut = do
475518 e <- runEitherT action
@@ -482,8 +525,14 @@ instance HasServer (Put ctypes ()) where
482525 | otherwise = respond $ failWith NotFound
483526
484527-- Add response headers
485−instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
528+instance
529+#if MIN_VERSION_base(4,8,0)
530+ {-# OVERLAPPING #-}
531+#endif
532+ ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
533+
486534 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
535+
487536 route Proxy action request respond
488537 | pathIsEmpty request && requestMethod request == methodPut = do
489538 e <- runEitherT action
@@ -512,8 +561,12 @@ instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
512561-- If successfully returning a value, we just require that its type has
513562-- a 'ToJSON' instance and servant takes care of encoding it for you,
514563-- yielding status code 200 along the way.
515−instance ( AllCTRender ctypes a
516− ) => HasServer (Patch ctypes a) where
564+instance
565+#if MIN_VERSION_base(4,8,0)
566+ {-# OVERLAPPABLE #-}
567+#endif
568+ ( AllCTRender ctypes a) => HasServer (Patch ctypes a) where
569+
517570 type ServerT' (Patch ctypes a) m = m a
518571
519572 route Proxy action request respond
@@ -532,8 +585,14 @@ instance ( AllCTRender ctypes a
532585 respond $ failWith WrongMethod
533586 | otherwise = respond $ failWith NotFound
534587
535−instance HasServer (Patch ctypes ()) where
588+instance
589+#if MIN_VERSION_base(4,8,0)
590+ {-# OVERLAPPING #-}
591+#endif
592+ HasServer (Patch ctypes ()) where
593+
536594 type ServerT' (Patch ctypes ()) m = m ()
595+
537596 route Proxy action request respond
538597 | pathIsEmpty request && requestMethod request == methodPatch = do
539598 e <- runEitherT action
@@ -546,8 +605,14 @@ instance HasServer (Patch ctypes ()) where
546605 | otherwise = respond $ failWith NotFound
547606
548607-- Add response headers
549−instance ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
608+instance
609+#if MIN_VERSION_base(4,8,0)
610+ {-# OVERLAPPING #-}
611+#endif
612+ ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
613+
550614 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
615+
551616 route Proxy action request respond
552617 | pathIsEmpty request && requestMethod request == methodPatch = do
553618 e <- runEitherT action