From 9bdecdcb1949b728818cc0312d625f17c8588b0a Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Tue, 16 Jan 2024 12:50:03 +0000 Subject: [PATCH] Use ReaderT instead of DerivingVia because of ghc 8.4 --- Cabal/src/Distribution/Simple/Build/Monad.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Build/Monad.hs b/Cabal/src/Distribution/Simple/Build/Monad.hs index 7aab514dfdf..e40232b689a 100644 --- a/Cabal/src/Distribution/Simple/Build/Monad.hs +++ b/Cabal/src/Distribution/Simple/Build/Monad.hs @@ -1,8 +1,9 @@ -{-# LANGUAGE DerivingVia #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Distribution.Simple.Build.Monad - ( BuildM (..) + ( BuildM (BuildM) , runBuildM , PreBuildComponentInputs (..) @@ -49,8 +50,14 @@ data PreBuildComponentInputs = PreBuildComponentInputs } -- | Computations carried out in the context of building a component (e.g. @'buildAllExtraSources'@) -newtype BuildM a = BuildM (PreBuildComponentInputs -> IO a) - deriving (Functor, Applicative, Monad, MonadReader PreBuildComponentInputs, MonadIO) via ReaderT PreBuildComponentInputs IO +newtype BuildM a = BuildM' (ReaderT PreBuildComponentInputs IO a) + deriving (Functor, Applicative, Monad, MonadReader PreBuildComponentInputs, MonadIO) +-- Ideally we'd use deriving via ReaderT PreBuildComponentInputs IO, but ghc 8.4 doesn't support it. + +-- | Construct a t'BuildM' action from an IO function on 'PreBuildComponentInputs'. +pattern BuildM :: (PreBuildComponentInputs -> IO a) -> BuildM a +pattern BuildM f = BuildM' (ReaderT f) +{-# COMPLETE BuildM #-} -- | Run a 'BuildM' action, i.e. a computation in the context of building a component. runBuildM :: BuildingWhat -> LocalBuildInfo -> TargetInfo -> BuildM a -> IO a