@@ -1,12 +1,15 @@
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE OverlappingInstances #-}
5{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE PolyKinds #-}
6{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
9{-# LANGUAGE TypeOperators #-}
9{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
11+{-# LANGUAGE OverlappingInstances #-}
10module Servant.Server.Internal where
13module Servant.Server.Internal where
12import Control.Applicative ((<$>))
15import Control.Applicative ((<$>))
@@ -280,8 +283,11 @@ instance HasServer Delete where
280-- (returning a status code of 200). If there was no @Accept@ header or it
283-- (returning a status code of 200). If there was no @Accept@ header or it
281-- was @*/*@, we return encode using the first @Content-Type@ type on the
284-- was @*/*@, we return encode using the first @Content-Type@ type on the
283−instance ( AllCTRender ctypes a
286+instance
287+#if MIN_VERSION_base(4,8,0)
288+ {-# OVERLAPPABLE #-}
284− ) => HasServer (Get ctypes a) where
290+ ( AllCTRender ctypes a ) => HasServer (Get ctypes a) where
286 type ServerT' (Get ctypes a) m = m a
292 type ServerT' (Get ctypes a) m = m a
@@ -302,8 +308,14 @@ instance ( AllCTRender ctypes a
302 | otherwise = respond $ failWith NotFound
308 | otherwise = respond $ failWith NotFound
304-- '()' ==> 204 No Content
310-- '()' ==> 204 No Content
312+#if MIN_VERSION_base(4,8,0)
305−instance HasServer (Get ctypes ()) where
315+ HasServer (Get ctypes ()) where
306 type ServerT' (Get ctypes ()) m = m ()
317 type ServerT' (Get ctypes ()) m = m ()
307 route Proxy action request respond
319 route Proxy action request respond
308 | pathIsEmpty request && requestMethod request == methodGet = do
320 | pathIsEmpty request && requestMethod request == methodGet = do
309 e <- runEitherT action
321 e <- runEitherT action
@@ -316,8 +328,14 @@ instance HasServer (Get ctypes ()) where
316 | otherwise = respond $ failWith NotFound
328 | otherwise = respond $ failWith NotFound
318-- Add response headers
330-- Add response headers
332+#if MIN_VERSION_base(4,8,0)
319−instance ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
335+ ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
320 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
337 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
321 route Proxy action request respond
339 route Proxy action request respond
322 | pathIsEmpty request && requestMethod request == methodGet = do
340 | pathIsEmpty request && requestMethod request == methodGet = do
323 e <- runEitherT action
341 e <- runEitherT action
@@ -380,7 +398,11 @@ instance (KnownSymbol sym, FromText a, HasServer sublayout)
380-- (returning a status code of 201). If there was no @Accept@ header or it
398-- (returning a status code of 201). If there was no @Accept@ header or it
381-- was @*/*@, we return encode using the first @Content-Type@ type on the
399-- was @*/*@, we return encode using the first @Content-Type@ type on the
402+#if MIN_VERSION_base(4,8,0)
403+ {-# OVERLAPPABLE #-}
383−instance ( AllCTRender ctypes a
405+ ( AllCTRender ctypes a
384 ) => HasServer (Post ctypes a) where
406 ) => HasServer (Post ctypes a) where
386 type ServerT' (Post ctypes a) m = m a
408 type ServerT' (Post ctypes a) m = m a
@@ -401,8 +423,14 @@ instance ( AllCTRender ctypes a
401 respond $ failWith WrongMethod
423 respond $ failWith WrongMethod
402 | otherwise = respond $ failWith NotFound
424 | otherwise = respond $ failWith NotFound
427+#if MIN_VERSION_base(4,8,0)
404−instance HasServer (Post ctypes ()) where
430+ HasServer (Post ctypes ()) where
405 type ServerT' (Post ctypes ()) m = m ()
432 type ServerT' (Post ctypes ()) m = m ()
406 route Proxy action request respond
434 route Proxy action request respond
407 | pathIsEmpty request && requestMethod request == methodPost = do
435 | pathIsEmpty request && requestMethod request == methodPost = do
408 e <- runEitherT action
436 e <- runEitherT action
@@ -415,8 +443,14 @@ instance HasServer (Post ctypes ()) where
415 | otherwise = respond $ failWith NotFound
443 | otherwise = respond $ failWith NotFound
417-- Add response headers
445-- Add response headers
447+#if MIN_VERSION_base(4,8,0)
418−instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
450+ ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
419 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
452 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
420 route Proxy action request respond
454 route Proxy action request respond
421 | pathIsEmpty request && requestMethod request == methodPost = do
455 | pathIsEmpty request && requestMethod request == methodPost = do
422 e <- runEitherT action
456 e <- runEitherT action
@@ -447,8 +481,11 @@ instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
447-- (returning a status code of 200). If there was no @Accept@ header or it
481-- (returning a status code of 200). If there was no @Accept@ header or it
448-- was @*/*@, we return encode using the first @Content-Type@ type on the
482-- was @*/*@, we return encode using the first @Content-Type@ type on the
450−instance ( AllCTRender ctypes a
484+instance
485+#if MIN_VERSION_base(4,8,0)
486+ {-# OVERLAPPABLE #-}
451− ) => HasServer (Put ctypes a) where
488+ ( AllCTRender ctypes a) => HasServer (Put ctypes a) where
453 type ServerT' (Put ctypes a) m = m a
490 type ServerT' (Put ctypes a) m = m a
@@ -468,8 +505,14 @@ instance ( AllCTRender ctypes a
468 respond $ failWith WrongMethod
505 respond $ failWith WrongMethod
469 | otherwise = respond $ failWith NotFound
506 | otherwise = respond $ failWith NotFound
509+#if MIN_VERSION_base(4,8,0)
471−instance HasServer (Put ctypes ()) where
512+ HasServer (Put ctypes ()) where
472 type ServerT' (Put ctypes ()) m = m ()
514 type ServerT' (Put ctypes ()) m = m ()
473 route Proxy action request respond
516 route Proxy action request respond
474 | pathIsEmpty request && requestMethod request == methodPut = do
517 | pathIsEmpty request && requestMethod request == methodPut = do
475 e <- runEitherT action
518 e <- runEitherT action
@@ -482,8 +525,14 @@ instance HasServer (Put ctypes ()) where
482 | otherwise = respond $ failWith NotFound
525 | otherwise = respond $ failWith NotFound
484-- Add response headers
527-- Add response headers
529+#if MIN_VERSION_base(4,8,0)
485−instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
532+ ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
486 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
534 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
487 route Proxy action request respond
536 route Proxy action request respond
488 | pathIsEmpty request && requestMethod request == methodPut = do
537 | pathIsEmpty request && requestMethod request == methodPut = do
489 e <- runEitherT action
538 e <- runEitherT action
@@ -512,8 +561,12 @@ instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
512-- If successfully returning a value, we just require that its type has
561-- If successfully returning a value, we just require that its type has
513-- a 'ToJSON' instance and servant takes care of encoding it for you,
562-- a 'ToJSON' instance and servant takes care of encoding it for you,
514-- yielding status code 200 along the way.
563-- yielding status code 200 along the way.
515−instance ( AllCTRender ctypes a
564+instance
565+#if MIN_VERSION_base(4,8,0)
566+ {-# OVERLAPPABLE #-}
516− ) => HasServer (Patch ctypes a) where
568+ ( AllCTRender ctypes a) => HasServer (Patch ctypes a) where
517 type ServerT' (Patch ctypes a) m = m a
570 type ServerT' (Patch ctypes a) m = m a
519 route Proxy action request respond
572 route Proxy action request respond
@@ -532,8 +585,14 @@ instance ( AllCTRender ctypes a
532 respond $ failWith WrongMethod
585 respond $ failWith WrongMethod
533 | otherwise = respond $ failWith NotFound
586 | otherwise = respond $ failWith NotFound
589+#if MIN_VERSION_base(4,8,0)
535−instance HasServer (Patch ctypes ()) where
592+ HasServer (Patch ctypes ()) where
536 type ServerT' (Patch ctypes ()) m = m ()
594 type ServerT' (Patch ctypes ()) m = m ()
537 route Proxy action request respond
596 route Proxy action request respond
538 | pathIsEmpty request && requestMethod request == methodPatch = do
597 | pathIsEmpty request && requestMethod request == methodPatch = do
539 e <- runEitherT action
598 e <- runEitherT action
@@ -546,8 +605,14 @@ instance HasServer (Patch ctypes ()) where
546 | otherwise = respond $ failWith NotFound
605 | otherwise = respond $ failWith NotFound
548-- Add response headers
607-- Add response headers
609+#if MIN_VERSION_base(4,8,0)
549−instance ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
612+ ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
550 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
614 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
551 route Proxy action request respond
616 route Proxy action request respond
552 | pathIsEmpty request && requestMethod request == methodPatch = do
617 | pathIsEmpty request && requestMethod request == methodPatch = do
553 e <- runEitherT action
618 e <- runEitherT action