Skip to content

Commit

Permalink
Fix build on older versions of GHC
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriella439 committed Oct 24, 2024
1 parent fafaad5 commit 8825a60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Nix/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Reader (MonadReader, ReaderT, ask)
import Control.Monad.State (MonadState, StateT, get, put)
import Data.Attoparsec.Text (IResult(..), Parser)
import qualified Data.Functor as Functor (unzip)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Map (Map)
import Data.Maybe (catMaybes)
import Data.Set (Set)
import Data.Text (Text)
import Data.Vector (Vector)
import Nix.Derivation (Derivation, DerivationOutput)
import Prelude hiding (unzip)

import qualified Control.Monad.Reader
import qualified Data.Attoparsec.Text
Expand Down Expand Up @@ -49,6 +49,13 @@ import Nix.Diff.Types
import Nix.Diff.Store (StorePath (StorePath, unsafeStorePathFile))
import qualified Nix.Diff.Store as Store

#if MIN_VERSION_base(4,19,0)
import Data.Functor (unzip)
#else
unzip :: Functor f => f (a, b) -> (f a, f b)
unzip xs = (fst <$> xs, snd <$> xs)
#endif

newtype Status = Status { visited :: Set Diffed }

data Diffed = Diffed
Expand Down Expand Up @@ -506,7 +513,7 @@ diff topLevel leftPath leftOutputs rightPath rightOutputs = do
else Nothing

let assocs = Data.Map.toList (innerJoin leftInputs rightInputs)
(descended, mInputsDiff) <- Functor.unzip <$> forM assocs \(inputName, (leftPaths, rightPaths)) -> do
(descended, mInputsDiff) <- unzip <$> forM assocs \(inputName, (leftPaths, rightPaths)) -> do
let leftExtraPaths =
Data.Map.difference leftPaths rightPaths
let rightExtraPaths =
Expand Down

0 comments on commit 8825a60

Please sign in to comment.