Simplify instance declarations

Many instance declarations can now be derived either by DerivingVia or
GeneralizedNewtypeDeriving.
This commit is contained in:
Tony Zorman
2022-11-19 09:10:57 +01:00
parent 5d0013ef53
commit b96bb908db
4 changed files with 20 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleContexts #-}
{-# LANGUAGE DerivingVia, GeneralizedNewtypeDeriving, FlexibleContexts #-}
-----------------------------------------------------------------------------
-- |
@@ -110,12 +110,7 @@ import Control.Monad.Reader
-- | The @PureX@ newtype over @ReaderT XConf (State XState) a@.
newtype PureX a = PureX (ReaderT XConf (State XState) a)
deriving (Functor, Applicative, Monad, MonadReader XConf, MonadState XState)
instance Semigroup a => Semigroup (PureX a) where
(<>) = liftA2 (<>)
instance Monoid a => Monoid (PureX a) where
mempty = return mempty
deriving (Semigroup, Monoid) via Ap PureX a
-- | The @XLike@ typeclass over monads reading @XConf@ values and tracking
-- @XState@ state.