From e2b1ffadf8c6ea2000a99a38a32c9504af682d07 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 6 Oct 2024 15:39:24 +0200 Subject: [PATCH] Use explicit deriving strategies --- effectful-core/effectful-core.cabal | 5 ++++- effectful-core/src/Effectful/Error/Static.hs | 2 +- effectful-core/src/Effectful/Internal/Monad.hs | 2 +- effectful-core/src/Effectful/Internal/Unlift.hs | 8 ++++---- effectful-core/src/Effectful/NonDet.hs | 2 +- effectful-plugin/effectful-plugin.cabal | 5 ++++- effectful-plugin/tests/PluginTests.hs | 2 +- effectful-th/effectful-th.cabal | 5 ++++- effectful/bench/FileSizes.hs | 8 ++++---- effectful/effectful.cabal | 5 ++++- effectful/src/Effectful/Concurrent/Async.hs | 2 +- effectful/tests/Utils.hs | 3 ++- 12 files changed, 31 insertions(+), 18 deletions(-) diff --git a/effectful-core/effectful-core.cabal b/effectful-core/effectful-core.cabal index 3f02912..0d87bfc 100644 --- a/effectful-core/effectful-core.cabal +++ b/effectful-core/effectful-core.cabal @@ -29,7 +29,10 @@ source-repository head location: https://github.com/haskell-effectful/effectful.git common language - ghc-options: -Wall -Wcompat -Wno-unticked-promoted-constructors + ghc-options: -Wall + -Wcompat + -Wno-unticked-promoted-constructors + -Wmissing-deriving-strategies -Werror=prepositive-qualified-module default-language: Haskell2010 diff --git a/effectful-core/src/Effectful/Error/Static.hs b/effectful-core/src/Effectful/Error/Static.hs index 896b54a..b82117a 100644 --- a/effectful-core/src/Effectful/Error/Static.hs +++ b/effectful-core/src/Effectful/Error/Static.hs @@ -238,7 +238,7 @@ tryError m = (Right <$> m) `catchError` \es e -> pure $ Left (es, e) -- Helpers newtype ErrorId = ErrorId Unique - deriving Eq + deriving newtype Eq -- | A unique is picked so that distinct 'Error' handlers for the same type -- don't catch each other's exceptions. diff --git a/effectful-core/src/Effectful/Internal/Monad.hs b/effectful-core/src/Effectful/Internal/Monad.hs index e5a19fe..461011f 100644 --- a/effectful-core/src/Effectful/Internal/Monad.hs +++ b/effectful-core/src/Effectful/Internal/Monad.hs @@ -119,7 +119,7 @@ type role Eff nominal representational -- -- - Allows the effects to be handled in any order. newtype Eff (es :: [Effect]) a = Eff (Env es -> IO a) - deriving (Monoid, Semigroup) + deriving newtype (Monoid, Semigroup) -- | Run a pure 'Eff' computation. -- diff --git a/effectful-core/src/Effectful/Internal/Unlift.hs b/effectful-core/src/Effectful/Internal/Unlift.hs index 72c3ea6..c3ed328 100644 --- a/effectful-core/src/Effectful/Internal/Unlift.hs +++ b/effectful-core/src/Effectful/Internal/Unlift.hs @@ -96,7 +96,7 @@ data UnliftStrategy -- ^ The concurrent strategy makes it possible for the unlifting function to -- be called in threads distinct from its creator. See 'Persistence' and -- 'Limit' settings for more information. - deriving (Eq, Generic, Ord, Show) + deriving stock (Eq, Generic, Ord, Show) -- | Persistence setting for the 'ConcUnlift' strategy. -- @@ -116,7 +116,7 @@ data Persistence | Persistent -- ^ Persist the environment between calls to the unlifting function within a -- particular thread. - deriving (Eq, Generic, Ord, Show) + deriving stock (Eq, Generic, Ord, Show) -- | Limit setting for the 'ConcUnlift' strategy. data Limit @@ -135,7 +135,7 @@ data Limit -- when called in @N@ threads and @K+1@ copies when called in @K < N@ threads. | Unlimited -- ^ Unlimited use of the unlifting function. - deriving (Eq, Generic, Ord, Show) + deriving stock (Eq, Generic, Ord, Show) ---------------------------------------- -- Unlift functions @@ -229,7 +229,7 @@ persistentConcUnlift es0 cleanUp threads k = do -- Data types newtype EntryId = EntryId Int - deriving Eq + deriving newtype Eq newEntryId :: EntryId newEntryId = EntryId 0 diff --git a/effectful-core/src/Effectful/NonDet.hs b/effectful-core/src/Effectful/NonDet.hs index f7604df..43ceda2 100644 --- a/effectful-core/src/Effectful/NonDet.hs +++ b/effectful-core/src/Effectful/NonDet.hs @@ -47,7 +47,7 @@ data OnEmptyPolicy -- -- /Note:/ state modifications are rolled back on 'Empty' only. In particular, -- they are __not__ rolled back on exceptions. - deriving (Eq, Generic, Ord, Show) + deriving stock (Eq, Generic, Ord, Show) -- | Run the 'NonDet' effect with a given 'OnEmptyPolicy'. -- diff --git a/effectful-plugin/effectful-plugin.cabal b/effectful-plugin/effectful-plugin.cabal index 59a9124..d525df6 100644 --- a/effectful-plugin/effectful-plugin.cabal +++ b/effectful-plugin/effectful-plugin.cabal @@ -25,7 +25,10 @@ source-repository head location: https://github.com/haskell-effectful/effectful.git common language - ghc-options: -Wall -Wcompat -Wno-unticked-promoted-constructors + ghc-options: -Wall + -Wcompat + -Wno-unticked-promoted-constructors + -Wmissing-deriving-strategies -Werror=prepositive-qualified-module default-language: Haskell2010 diff --git a/effectful-plugin/tests/PluginTests.hs b/effectful-plugin/tests/PluginTests.hs index 7f46741..2a4e1e1 100644 --- a/effectful-plugin/tests/PluginTests.hs +++ b/effectful-plugin/tests/PluginTests.hs @@ -72,7 +72,7 @@ errState = do err newtype MyString = MyString String - deriving (IsString, Eq, Show) + deriving newtype (IsString, Eq, Show) data Janky = forall s. Janky (forall _i. Eff '[State s] ()) diff --git a/effectful-th/effectful-th.cabal b/effectful-th/effectful-th.cabal index 02338b0..e70c011 100644 --- a/effectful-th/effectful-th.cabal +++ b/effectful-th/effectful-th.cabal @@ -25,7 +25,10 @@ source-repository head location: https://github.com/haskell-effectful/effectful.git common language - ghc-options: -Wall -Wcompat -Wno-unticked-promoted-constructors + ghc-options: -Wall + -Wcompat + -Wno-unticked-promoted-constructors + -Wmissing-deriving-strategies -Werror=prepositive-qualified-module default-language: Haskell2010 diff --git a/effectful/bench/FileSizes.hs b/effectful/bench/FileSizes.hs index 3efd31d..570a069 100644 --- a/effectful/bench/FileSizes.hs +++ b/effectful/bench/FileSizes.hs @@ -363,7 +363,7 @@ fe_tryFileSize :: FE.Has FE_File sig m => FilePath -> m (Maybe Int) fe_tryFileSize = FE.send . FE_tryFileSize newtype FE_FileC m a = FE_FileC { fe_runFileC :: m a } - deriving (Applicative, Functor, Monad, MonadIO) + deriving newtype (Applicative, Functor, Monad, MonadIO) instance ( MonadIO m @@ -380,7 +380,7 @@ fe_logMsg :: FE.Has FE_Logging sig m => String -> m () fe_logMsg = FE.send . FE_logMsg . T.pack newtype FE_LoggingC m a = FE_LoggingC { fe_runLoggingC :: FE.StateC [Text] m a } - deriving (Applicative, Functor, Monad) + deriving newtype (Applicative, Functor, Monad) instance ( FE.Algebra sig m @@ -440,7 +440,7 @@ class Monad m => MonadFile m where mtl_tryFileSize :: FilePath -> m (Maybe Int) newtype FileT m a = FileT { runFileT :: m a } - deriving (Functor, Applicative, Monad, MonadIO) + deriving newtype (Functor, Applicative, Monad, MonadIO) instance M.MonadTrans FileT where lift = FileT @@ -459,7 +459,7 @@ class Monad m => MonadLog m where mtl_logMsg :: String -> m () newtype LoggingT m a = LoggingT (M.StateT [Text] m a) - deriving (Functor, Applicative, Monad, MonadIO, M.MonadTrans) + deriving newtype (Functor, Applicative, Monad, MonadIO, M.MonadTrans) instance {-# OVERLAPPABLE #-} ( MonadLog m diff --git a/effectful/effectful.cabal b/effectful/effectful.cabal index 8b0f490..39a03b2 100644 --- a/effectful/effectful.cabal +++ b/effectful/effectful.cabal @@ -34,7 +34,10 @@ flag benchmark-foreign-libraries default: False common language - ghc-options: -Wall -Wcompat -Wno-unticked-promoted-constructors + ghc-options: -Wall + -Wcompat + -Wno-unticked-promoted-constructors + -Wmissing-deriving-strategies -Werror=prepositive-qualified-module default-language: Haskell2010 diff --git a/effectful/src/Effectful/Concurrent/Async.hs b/effectful/src/Effectful/Concurrent/Async.hs index 018d307..9d76aaa 100644 --- a/effectful/src/Effectful/Concurrent/Async.hs +++ b/effectful/src/Effectful/Concurrent/Async.hs @@ -474,7 +474,7 @@ data Conc :: [Effect] -> Type -> Type where Alt :: Conc es a -> Conc es a -> Conc es a Empty :: Conc es a -deriving instance Functor (Conc es) +deriving stock instance Functor (Conc es) instance Applicative (Conc es) where pure = Pure diff --git a/effectful/tests/Utils.hs b/effectful/tests/Utils.hs index 38a8ec0..4f352d3 100644 --- a/effectful/tests/Utils.hs +++ b/effectful/tests/Utils.hs @@ -43,5 +43,6 @@ assertThrowsErrorCall => String -> Eff es a -> Eff es () assertThrowsErrorCall err = assertThrows err (\ErrorCall{} -> True) -data Ex = Ex deriving (Eq, Show) +data Ex = Ex + deriving stock (Eq, Show) instance Exception Ex