Skip to content

Commit

Permalink
Use OverloadedRecordDot & NoFieldSelectors (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years authored Oct 25, 2024
1 parent 035b926 commit 8ffcea4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ main = do
let renderContext = RenderContext {..}
let status = Status Data.Set.empty
let action = diff True (StorePath left) (OutputNames (Data.Set.singleton "out")) (StorePath right) (OutputNames (Data.Set.singleton "out"))
diffTree <- Control.Monad.State.evalStateT (Control.Monad.Reader.runReaderT (unDiff action) diffContext) status
diffTree <- Control.Monad.State.evalStateT (Control.Monad.Reader.runReaderT action.unDiff diffContext) status
let diffTree' =
transformDiff transformOptions diffTree
renderDiff renderRunner renderContext diffTree'
2 changes: 2 additions & 0 deletions nix-diff.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ common language
LambdaCase,
MultiWayIf,
NamedFieldPuns,
NoFieldSelectors,
OverloadedRecordDot,
OverloadedStrings,
RecordWildCards,
ghc-options: -Wall
Expand Down
6 changes: 3 additions & 3 deletions src/Nix/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ data Orientation = Character | Word | Line
underneath `/nix/store`, but this is the overwhelmingly common use case
-}
derivationName :: StorePath -> Text
derivationName = Text.dropEnd 4 . Text.drop 44 . Text.pack . unsafeStorePathFile
derivationName storePath = Text.dropEnd 4 (Text.drop 44 (Text.pack storePath.unsafeStorePathFile))

-- | Group paths by their name
groupByName :: Map StorePath a -> Map Text (Map StorePath a)
Expand All @@ -109,7 +109,7 @@ groupByName m = Data.Map.fromList assocs
> /nix/store/${32_CHARACTER_HASH}-${NAME}.drv
-}
buildProductName :: StorePath -> Text
buildProductName = Text.drop 44 . Text.pack . unsafeStorePathFile
buildProductName storePath = Text.drop 44 (Text.pack storePath.unsafeStorePathFile)

-- | Like `groupByName`, but for `Set`s
groupSetsByName :: Set StorePath -> Map Text (Set StorePath)
Expand Down Expand Up @@ -157,7 +157,7 @@ readDerivation sp = do
-- queried.
readInput :: StorePath -> Diff (Derivation StorePath Text)
readInput pathAndMaybeOutput = do
let (path, _) = List.break (== '!') (Store.unsafeStorePathFile pathAndMaybeOutput)
let (path, _) = List.break (== '!') pathAndMaybeOutput.unsafeStorePathFile
if FilePath.isExtensionOf ".drv" path
then readDerivation (StorePath path)
else do
Expand Down
4 changes: 2 additions & 2 deletions src/Nix/Diff/Render/HumanReadable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ newtype Render a = Render { unRender :: ReaderT RenderContext (Writer Text) a}
)

runRender :: Render a -> RenderContext -> (a, Text)
runRender render rc = runWriter $ runReaderT (unRender render) rc
runRender render rc = runWriter $ runReaderT render.unRender rc

runRender' :: Render () -> RenderContext -> Text
runRender' render = snd . runRender render
Expand All @@ -56,7 +56,7 @@ echo text = do
indented :: Natural -> Render a -> Render a
indented n = local adapt
where
adapt context = context { indent = indent context + n }
adapt context = context { indent = context.indent + n }

data TTY = IsTTY | NotTTY

Expand Down
2 changes: 1 addition & 1 deletion src/Nix/Diff/Transformations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ foldManyInputDerivationsAlreadyCompared dd = case dd of
{ inputsDiff =
inputsDiff'
{ inputDerivationDiffs =
helper [] (inputDerivationDiffs inputsDiff')
helper [] inputsDiff'.inputDerivationDiffs
}
, ..
}
Expand Down
4 changes: 2 additions & 2 deletions src/Nix/Diff/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ instance Arbitrary TextDiff where
arbitrary = TextDiff <$> listOf arbitraryItem

instance ToJSON TextDiff where
toJSON = listValue itemToJSON . unTextDiff
toJSON textDiff = listValue itemToJSON textDiff.unTextDiff

instance FromJSON TextDiff where
parseJSON v = TextDiff <$> (traverse itemFromJSON =<< parseJSON v)
Expand Down Expand Up @@ -187,7 +187,7 @@ instance Arbitrary ArgumentsDiff where
arbitrary = ArgumentsDiff . NonEmpty.fromList <$> listOf1 arbitraryItem

instance ToJSON ArgumentsDiff where
toJSON = listValue itemToJSON . toList . unArgumetsDiff
toJSON argumentsDiff = listValue itemToJSON (toList argumentsDiff.unArgumetsDiff)

instance FromJSON ArgumentsDiff where
parseJSON v = ArgumentsDiff <$> (traverse itemFromJSON =<< parseJSON v)
Expand Down
2 changes: 1 addition & 1 deletion test/Golden/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ makeDiffTree :: TestableDerivations -> DiffContext -> IO DerivationDiff
makeDiffTree TestableDerivations{..} diffContext = do
let status = Status Data.Set.empty
let action = diff True oldDerivation (OutputNames (Data.Set.singleton "out")) newDerivation (OutputNames (Data.Set.singleton "out"))
Control.Monad.State.evalStateT (Control.Monad.Reader.runReaderT (unDiff action) diffContext) status
Control.Monad.State.evalStateT (Control.Monad.Reader.runReaderT action.unDiff diffContext) status

-- | Drop conventional stdout newline, convert to StorePath
storePathFromCLI :: BS.ByteString -> StorePath
Expand Down

0 comments on commit 8ffcea4

Please sign in to comment.