From 7c0e466fddadb572615c0c0dd2c4d1a5708c9ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Choutri?= Date: Thu, 25 Apr 2024 18:43:49 +0200 Subject: [PATCH] Remove useless extensions in servant package --- servant/src/Servant/API/Alternative.hs | 3 --- servant/src/Servant/API/BasicAuth.hs | 2 +- servant/src/Servant/API/ContentTypes.hs | 2 +- servant/src/Servant/API/Experimental/Auth.hs | 2 +- servant/src/Servant/API/Fragment.hs | 2 +- servant/src/Servant/API/Modifiers.hs | 2 +- servant/src/Servant/API/QueryParam.hs | 2 +- servant/src/Servant/API/QueryString.hs | 3 --- servant/src/Servant/API/ResponseHeaders.hs | 4 ++-- servant/src/Servant/API/Stream.hs | 4 ++-- servant/src/Servant/API/TypeLevel.hs | 2 +- servant/src/Servant/API/UVerb.hs | 4 ++-- servant/src/Servant/API/UVerb/Union.hs | 4 ++-- servant/src/Servant/API/Verbs.hs | 2 +- servant/src/Servant/Links.hs | 5 ++--- servant/src/Servant/Types/SourceT.hs | 12 ++++++------ 16 files changed, 24 insertions(+), 31 deletions(-) diff --git a/servant/src/Servant/API/Alternative.hs b/servant/src/Servant/API/Alternative.hs index e87dd3940..eba9efcdd 100644 --- a/servant/src/Servant/API/Alternative.hs +++ b/servant/src/Servant/API/Alternative.hs @@ -1,7 +1,4 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_HADDOCK not-home #-} diff --git a/servant/src/Servant/API/BasicAuth.hs b/servant/src/Servant/API/BasicAuth.hs index cdfa88bd4..38d74bd79 100644 --- a/servant/src/Servant/API/BasicAuth.hs +++ b/servant/src/Servant/API/BasicAuth.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE PolyKinds #-} module Servant.API.BasicAuth where diff --git a/servant/src/Servant/API/ContentTypes.hs b/servant/src/Servant/API/ContentTypes.hs index fea16933a..7d461208f 100644 --- a/servant/src/Servant/API/ContentTypes.hs +++ b/servant/src/Servant/API/ContentTypes.hs @@ -397,7 +397,7 @@ instance MimeUnrender PlainText String where -- | @Right . id@ instance MimeUnrender OctetStream ByteString where - mimeUnrender _ = Right . id + mimeUnrender _ = Right -- | @Right . toStrict@ instance MimeUnrender OctetStream BS.ByteString where diff --git a/servant/src/Servant/API/Experimental/Auth.hs b/servant/src/Servant/API/Experimental/Auth.hs index 586b49589..3064838fd 100644 --- a/servant/src/Servant/API/Experimental/Auth.hs +++ b/servant/src/Servant/API/Experimental/Auth.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE PolyKinds #-} module Servant.API.Experimental.Auth where diff --git a/servant/src/Servant/API/Fragment.hs b/servant/src/Servant/API/Fragment.hs index e6a33f03c..c6d752e49 100644 --- a/servant/src/Servant/API/Fragment.hs +++ b/servant/src/Servant/API/Fragment.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeOperators #-} + {-# OPTIONS_HADDOCK not-home #-} module Servant.API.Fragment (Fragment) where diff --git a/servant/src/Servant/API/Modifiers.hs b/servant/src/Servant/API/Modifiers.hs index ee756d3a0..b4c64d80e 100644 --- a/servant/src/Servant/API/Modifiers.hs +++ b/servant/src/Servant/API/Modifiers.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} diff --git a/servant/src/Servant/API/QueryParam.hs b/servant/src/Servant/API/QueryParam.hs index c87a8231e..799d9f546 100644 --- a/servant/src/Servant/API/QueryParam.hs +++ b/servant/src/Servant/API/QueryParam.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeOperators #-} + {-# OPTIONS_HADDOCK not-home #-} module Servant.API.QueryParam (QueryFlag, QueryParam, QueryParam', QueryParams) where diff --git a/servant/src/Servant/API/QueryString.hs b/servant/src/Servant/API/QueryString.hs index 837773ebc..404d6d226 100644 --- a/servant/src/Servant/API/QueryString.hs +++ b/servant/src/Servant/API/QueryString.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleInstances #-} @@ -11,9 +10,7 @@ module Servant.API.QueryString (QueryString, DeepQuery, FromDeepQuery (..), ToDeepQuery (..), generateDeepParam) where import Data.Bifunctor (Bifunctor (first)) -#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) -#endif import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Text (Text) diff --git a/servant/src/Servant/API/ResponseHeaders.hs b/servant/src/Servant/API/ResponseHeaders.hs index 92fe3b131..14115c2a6 100644 --- a/servant/src/Servant/API/ResponseHeaders.hs +++ b/servant/src/Servant/API/ResponseHeaders.hs @@ -7,7 +7,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeFamilies #-} + {-# LANGUAGE TypeFamilyDependencies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} @@ -184,7 +184,7 @@ instance {-# OVERLAPPABLE #-} ( KnownSymbol h, ToHttpApiData v , new ~ Headers ' -- responses if the list is empty). instance (AddHeader mods h v old new) => AddHeader mods h v (Union '[old]) (Union '[new]) where addOptionalHeader hdr resp = - SOP.Z $ SOP.I $ addOptionalHeader hdr $ SOP.unI $ SOP.unZ $ resp + SOP.Z $ SOP.I $ addOptionalHeader hdr $ SOP.unI $ SOP.unZ resp instance ( AddHeader mods h v old new, AddHeader mods h v (Union oldrest) (Union newrest) diff --git a/servant/src/Servant/API/Stream.hs b/servant/src/Servant/API/Stream.hs index 3f8810eda..f6a89ff9d 100644 --- a/servant/src/Servant/API/Stream.hs +++ b/servant/src/Servant/API/Stream.hs @@ -4,8 +4,8 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE MultiParamTypeClasses #-} + + {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} diff --git a/servant/src/Servant/API/TypeLevel.hs b/servant/src/Servant/API/TypeLevel.hs index ae631bf26..e09cba47c 100644 --- a/servant/src/Servant/API/TypeLevel.hs +++ b/servant/src/Servant/API/TypeLevel.hs @@ -2,7 +2,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} diff --git a/servant/src/Servant/API/UVerb.hs b/servant/src/Servant/API/UVerb.hs index a9c3b70af..96eb60d92 100644 --- a/servant/src/Servant/API/UVerb.hs +++ b/servant/src/Servant/API/UVerb.hs @@ -1,7 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} + {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -10,7 +10,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} + -- | An alternative to 'Verb' for end-points that respond with a resource value of any of an -- open union of types, and specific status codes for each type in this union. (`UVerb` is diff --git a/servant/src/Servant/API/UVerb/Union.hs b/servant/src/Servant/API/UVerb/Union.hs index d8c3943e2..2ed14ba7c 100644 --- a/servant/src/Servant/API/UVerb/Union.hs +++ b/servant/src/Servant/API/UVerb/Union.hs @@ -1,9 +1,9 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE ExplicitNamespaces #-} + {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} diff --git a/servant/src/Servant/API/Verbs.hs b/servant/src/Servant/API/Verbs.hs index 4980e87e7..fbe77e656 100644 --- a/servant/src/Servant/API/Verbs.hs +++ b/servant/src/Servant/API/Verbs.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE KindSignatures #-} + {-# LANGUAGE PolyKinds #-} module Servant.API.Verbs ( module Servant.API.Verbs diff --git a/servant/src/Servant/Links.hs b/servant/src/Servant/Links.hs index 907075e75..b1fb95693 100644 --- a/servant/src/Servant/Links.hs +++ b/servant/src/Servant/Links.hs @@ -1,10 +1,9 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE QuantifiedConstraints #-} @@ -13,8 +12,8 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} - {-# OPTIONS_HADDOCK not-home #-} +{-# LANGUAGE MultiParamTypeClasses #-} -- | Type safe generation of internal links. -- diff --git a/servant/src/Servant/Types/SourceT.hs b/servant/src/Servant/Types/SourceT.hs index 69c2c8bfe..a03828edd 100644 --- a/servant/src/Servant/Types/SourceT.hs +++ b/servant/src/Servant/Types/SourceT.hs @@ -89,7 +89,7 @@ instance (Applicative m, Show1 m, Show a) => Show (SourceT m a) where -- fromStepT (Effect (Just (Yield 1 (Yield 2 (Yield 3 Stop))))) instance MFunctor SourceT where hoist f (SourceT m) = SourceT $ \k -> k $ - Effect $ f $ fmap (hoist f) $ m return + Effect $ f $ fmap (hoist f) $ m pure -- | >>> source "xy" <> source "z" :: SourceT Identity Char -- fromStepT (Effect (Identity (Yield 'x' (Yield 'y' (Yield 'z' Stop))))) @@ -197,7 +197,7 @@ instance (QC.Arbitrary a, Monad m) => QC.Arbitrary (StepT m a) where | otherwise = QC.frequency [ (1, pure Stop) , (1, Skip <$> arb') - , (1, Effect . return <$> arb') + , (1, Effect . pure <$> arb') , (8, Yield <$> QC.arbitrary <*> arb') ] where @@ -235,7 +235,7 @@ runSourceT :: Monad m => SourceT m a -> ExceptT String m [a] runSourceT (SourceT m) = ExceptT (m (runExceptT . runStepT)) runStepT :: Monad m => StepT m a -> ExceptT String m [a] -runStepT Stop = return [] +runStepT Stop = pure [] runStepT (Error err) = throwError err runStepT (Skip s) = runStepT s runStepT (Yield x s) = fmap (x :) (runStepT s) @@ -246,9 +246,9 @@ runStepT (Effect ms) = lift ms >>= runStepT -- Identity (Just ('f',Yield 'o' (Yield 'o' Stop))) -- uncons :: Monad m => StepT m a -> m (Maybe (a, StepT m a)) -uncons Stop = return Nothing +uncons Stop = pure Nothing uncons (Skip s) = uncons s -uncons (Yield x s) = return (Just (x, s)) +uncons (Yield x s) = pure (Just (x, s)) uncons (Effect ms) = ms >>= uncons uncons (Error _) = -} @@ -298,7 +298,7 @@ foreachStep -> StepT m a -> m () foreachStep f g = go where - go Stop = return () + go Stop = pure () go (Skip s) = go s go (Yield x s) = g x >> go s go (Error err) = f err