Skip to content

Commit fc514d6

Browse files
authored
Merge pull request #6459 from commercialhaskell/newtype-prefix
Remove prefixes from newtype fields
2 parents 6103fc5 + 5f0af1f commit fc514d6

File tree

10 files changed

+27
-26
lines changed

10 files changed

+27
-26
lines changed

src/Stack/Ghci/Script.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Distribution.ModuleName ( ModuleName, components )
1919
import Stack.Prelude
2020
import System.IO ( hSetBinaryMode )
2121

22-
newtype GhciScript = GhciScript { unGhciScript :: [GhciCommand] }
22+
newtype GhciScript = GhciScript { ghciScript :: [GhciCommand] }
2323

2424
instance Semigroup GhciScript where
2525
GhciScript xs <> GhciScript ys = GhciScript (ys <> xs)
@@ -45,7 +45,7 @@ scriptToLazyByteString = toLazyByteString . scriptToBuilder
4545
scriptToBuilder :: GhciScript -> Builder
4646
scriptToBuilder backwardScript = mconcat $ fmap commandToBuilder script
4747
where
48-
script = reverse backwardScript.unGhciScript
48+
script = reverse backwardScript.ghciScript
4949

5050
scriptToFile :: Path Abs File -> GhciScript -> IO ()
5151
scriptToFile path script =

src/Stack/Lock.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ instance ( FromJSON (WithJSONWarnings (Unresolved a))
7676
-- serialization should not produce locations with multiple subdirs
7777
-- so we should be OK using just a head element
7878
newtype SingleRPLI
79-
= SingleRPLI { unSingleRPLI :: RawPackageLocationImmutable}
79+
= SingleRPLI { singleRPLI :: RawPackageLocationImmutable}
8080

8181
instance FromJSON (WithJSONWarnings (Unresolved SingleRPLI)) where
8282
parseJSON v =
@@ -103,7 +103,7 @@ instance FromJSON (WithJSONWarnings (Unresolved Locked)) where
103103
snapshots <- jsonSubWarningsT $ o ..: "snapshots"
104104
packages <- jsonSubWarningsT $ o ..: "packages"
105105
let unwrap :: LockedLocation SingleRPLI b -> LockedLocation RawPackageLocationImmutable b
106-
unwrap ll = ll { original = ll.original.unSingleRPLI }
106+
unwrap ll = ll { original = ll.original.singleRPLI }
107107
pure $ Locked <$> sequenceA snapshots <*> (map unwrap <$> sequenceA packages)
108108

109109
loadYamlThrow ::

src/Stack/Ls.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ instance Exception LsException where
7373

7474
-- | Type representing command line options for the @stack ls@ command.
7575
newtype LsCmdOpts
76-
= LsCmdOpts { lsView :: LsCmds }
76+
= LsCmdOpts { lsCmds :: LsCmds }
7777

7878
-- | Type representing subcommands for the @stack ls@ command.
7979
data LsCmds
@@ -143,7 +143,7 @@ data ListStylesOpts = ListStylesOpts
143143

144144
-- | Type representing command line options for the @stack ls tools@ command.
145145
newtype ListToolsOpts
146-
= ListToolsOpts { toptFilter :: String }
146+
= ListToolsOpts { filter :: String }
147147

148148
data Snapshot = Snapshot
149149
{ snapId :: Text
@@ -236,7 +236,7 @@ handleLocal lsOpts = do
236236
| otherwise = parent parentInstRoot
237237
snapData' <- liftIO $ listDirectory $ toFilePath snapRootDir
238238
let snapData = L.sort snapData'
239-
case lsOpts.lsView of
239+
case lsOpts.lsCmds of
240240
LsSnapshot sopt ->
241241
case (sopt.ltsSnapView, sopt.nightlySnapView) of
242242
(True, False) ->
@@ -259,7 +259,7 @@ handleRemote lsOpts = do
259259
let req' = addRequestHeader hAccept "application/json" req
260260
result <- httpJSON req'
261261
let snapData = getResponseBody result
262-
case lsOpts.lsView of
262+
case lsOpts.lsCmds of
263263
LsSnapshot sopt ->
264264
case (sopt.ltsSnapView, sopt.nightlySnapView) of
265265
(True, False) ->
@@ -279,7 +279,7 @@ handleRemote lsOpts = do
279279

280280
lsCmd :: LsCmdOpts -> RIO Runner ()
281281
lsCmd lsOpts =
282-
case lsOpts.lsView of
282+
case lsOpts.lsCmds of
283283
LsSnapshot sopt ->
284284
case sopt.viewType of
285285
Local -> handleLocal lsOpts
@@ -320,7 +320,7 @@ listToolsCmd :: ListToolsOpts -> RIO Config ()
320320
listToolsCmd opts = do
321321
localPrograms <- view $ configL . to (.localPrograms)
322322
installed <- sort <$> listInstalled localPrograms
323-
let wanted = case opts.toptFilter of
323+
let wanted = case opts.filter of
324324
[] -> installed
325325
"ghc-git" -> [t | t@(ToolGhcGit _ _) <- installed]
326326
pkgName -> filtered pkgName installed

src/Stack/Prelude.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
2+
{-# LANGUAGE NoFieldSelectors #-}
23
{-# LANGUAGE OverloadedRecordDot #-}
34
{-# LANGUAGE OverloadedStrings #-}
45

@@ -272,7 +273,7 @@ promptBool txt = liftIO $ do
272273

273274
-- | Like @First Bool@, but the default is @True@.
274275
newtype FirstTrue
275-
= FirstTrue { getFirstTrue :: Maybe Bool }
276+
= FirstTrue { firstTrue :: Maybe Bool }
276277
deriving (Eq, Ord, Show)
277278

278279
instance Semigroup FirstTrue where
@@ -285,15 +286,15 @@ instance Monoid FirstTrue where
285286

286287
-- | Get the 'Bool', defaulting to 'True'
287288
fromFirstTrue :: FirstTrue -> Bool
288-
fromFirstTrue = fromMaybe True . (.getFirstTrue)
289+
fromFirstTrue = fromMaybe True . (.firstTrue)
289290

290291
-- | Helper for filling in default values
291292
defaultFirstTrue :: FirstTrue -> Bool
292293
defaultFirstTrue _ = True
293294

294295
-- | Like @First Bool@, but the default is @False@.
295296
newtype FirstFalse
296-
= FirstFalse { getFirstFalse :: Maybe Bool }
297+
= FirstFalse { firstFalse :: Maybe Bool }
297298
deriving (Eq, Ord, Show)
298299

299300
instance Semigroup FirstFalse where
@@ -306,7 +307,7 @@ instance Monoid FirstFalse where
306307

307308
-- | Get the 'Bool', defaulting to 'False'
308309
fromFirstFalse :: FirstFalse -> Bool
309-
fromFirstFalse = fromMaybe False . (.getFirstFalse)
310+
fromFirstFalse = fromMaybe False . (.firstFalse)
310311

311312
-- | Helper for filling in default values
312313
defaultFirstFalse :: FirstFalse -> Bool

src/Stack/Storage/Project.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ withProjectStorage ::
9898
=> ReaderT SqlBackend (RIO env) a
9999
-> RIO env a
100100
withProjectStorage inner = do
101-
storage <- view (buildConfigL . to (.projectStorage.unProjectStorage))
101+
storage <- view (buildConfigL . to (.projectStorage.projectStorage))
102102
withStorage_ storage inner
103103

104104
-- | Key used to retrieve configuration or flag cache

src/Stack/Storage/User.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ withUserStorage ::
168168
=> ReaderT SqlBackend (RIO env) a
169169
-> RIO env a
170170
withUserStorage inner = do
171-
storage <- view (configL . to (.userStorage.unUserStorage))
171+
storage <- view (configL . to (.userStorage.userStorage))
172172
withStorage_ storage inner
173173

174174
-- | Key used to retrieve the precompiled cache

src/Stack/Types/BuildOptsMonoid.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ newtype CabalVerbosity
337337
deriving (Eq, Show)
338338

339339
toFirstCabalVerbosity :: FirstFalse -> First CabalVerbosity
340-
toFirstCabalVerbosity vf = First $ vf.getFirstFalse <&> \p ->
340+
toFirstCabalVerbosity vf = First $ vf.firstFalse <&> \p ->
341341
if p then verboseLevel else normalLevel
342342
where
343343
verboseLevel = CabalVerbosity verbose
@@ -355,22 +355,22 @@ instance Parsec CabalVerbosity where
355355

356356
buildOptsMonoidHaddockL :: Lens' BuildOptsMonoid (Maybe Bool)
357357
buildOptsMonoidHaddockL =
358-
lens (.buildHaddocks.getFirstFalse)
358+
lens (.buildHaddocks.firstFalse)
359359
(\buildMonoid t -> buildMonoid {buildHaddocks = FirstFalse t})
360360

361361
buildOptsMonoidTestsL :: Lens' BuildOptsMonoid (Maybe Bool)
362362
buildOptsMonoidTestsL =
363-
lens (.tests.getFirstFalse)
363+
lens (.tests.firstFalse)
364364
(\buildMonoid t -> buildMonoid {tests = FirstFalse t})
365365

366366
buildOptsMonoidBenchmarksL :: Lens' BuildOptsMonoid (Maybe Bool)
367367
buildOptsMonoidBenchmarksL =
368-
lens (.benchmarks.getFirstFalse)
368+
lens (.benchmarks.firstFalse)
369369
(\buildMonoid t -> buildMonoid {benchmarks = FirstFalse t})
370370

371371
buildOptsMonoidInstallExesL :: Lens' BuildOptsMonoid (Maybe Bool)
372372
buildOptsMonoidInstallExesL =
373-
lens (.installExes.getFirstFalse)
373+
lens (.installExes.firstFalse)
374374
(\buildMonoid t -> buildMonoid {installExes = FirstFalse t})
375375

376376
-- Type representing formats of Stack's progress bar when building.

src/Stack/Types/ConfigMonoid.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ parseConfigMonoidObject rootDir obj = do
238238
skipGHCCheck <- FirstFalse <$> obj ..:? configMonoidSkipGHCCheckName
239239
skipMsys <- FirstFalse <$> obj ..:? configMonoidSkipMsysName
240240
requireStackVersion <-
241-
IntersectingVersionRange . (.unVersionRangeJSON) <$>
241+
IntersectingVersionRange . (.versionRangeJSON) <$>
242242
( obj ..:? configMonoidRequireStackVersionName
243243
..!= VersionRangeJSON anyVersion
244244
)

src/Stack/Types/Docker.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ instance FromJSON (WithJSONWarnings DockerOptsMonoid) where
354354
stackExe <- First <$> o ..:? dockerStackExeArgName
355355
setUser <- First <$> o ..:? dockerSetUserArgName
356356
requireDockerVersion <-
357-
IntersectingVersionRange . (.unVersionRangeJSON) <$>
357+
IntersectingVersionRange . (.versionRangeJSON) <$>
358358
( o ..:? dockerRequireDockerVersionArgName
359359
..!= VersionRangeJSON anyVersion
360360
)
@@ -444,7 +444,7 @@ data DockerMonoidRepoOrImage
444444

445445
-- | Newtype for non-orphan FromJSON instance.
446446
newtype VersionRangeJSON =
447-
VersionRangeJSON { unVersionRangeJSON :: VersionRange }
447+
VersionRangeJSON { versionRangeJSON :: VersionRange }
448448

449449
-- | Parse VersionRange.
450450
instance FromJSON VersionRangeJSON where

src/Stack/Types/Storage.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ instance Exception StoragePrettyException
5959

6060
-- | A bit of type safety to ensure we're talking to the right database.
6161
newtype UserStorage = UserStorage
62-
{ unUserStorage :: Storage
62+
{ userStorage :: Storage
6363
}
6464

6565
-- | A bit of type safety to ensure we're talking to the right database.
6666
newtype ProjectStorage = ProjectStorage
67-
{ unProjectStorage :: Storage
67+
{ projectStorage :: Storage
6868
}

0 commit comments

Comments
 (0)