Skip to content

Commit

Permalink
Use ReaderT instead of DerivingVia because of ghc 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Jan 16, 2024
1 parent 10eb129 commit 104b71e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Cabal/src/Distribution/Simple/Build/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Distribution.Simple.Build.Monad
( BuildM (..)
( BuildM (BuildM)
, runBuildM
, PreBuildComponentInputs (..)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 104b71e

Please sign in to comment.