Skip to content

Commit 2a3709f

Browse files
committed
treewide: m clean-up
1 parent a5f2209 commit 2a3709f

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

src/Nix/Convert.hs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fromMayToDeeperValue t v =
8383
do
8484
v' <- fromValueMay v
8585
maybe
86-
(throwError $ Expectation @t @f @m t (Free $ getDeeper v))
86+
(throwError $ Expectation @t @f @m t $ Free $ getDeeper v)
8787
pure
8888
v'
8989

@@ -154,7 +154,7 @@ instance Convertible e t f m
154154
fromValueMay =
155155
pure .
156156
\case
157-
NVConstant' (NInt b) -> pure (fromInteger b)
157+
NVConstant' (NInt b) -> pure $ fromInteger b
158158
_ -> Nothing
159159

160160
fromValue = fromMayToValue TInt
@@ -177,7 +177,7 @@ instance Convertible e t f m
177177
pure .
178178
\case
179179
NVConstant' (NFloat b) -> pure b
180-
NVConstant' (NInt i) -> pure (fromInteger i)
180+
NVConstant' (NInt i) -> pure $ fromInteger i
181181
_ -> Nothing
182182

183183
fromValue = fromMayToValue TFloat
@@ -202,7 +202,7 @@ instance ( Convertible e t f m
202202
(M.lookup "outPath" s)
203203
_ -> stub
204204

205-
fromValue = fromMayToValue (TString NoContext)
205+
fromValue = fromMayToValue $ TString NoContext
206206

207207
instance Convertible e t f m
208208
=> FromValue ByteString m (NValue' t f m (NValue t f m)) where
@@ -213,7 +213,7 @@ instance Convertible e t f m
213213
NVStr' ns -> encodeUtf8 <$> getStringNoContext ns
214214
_ -> mempty
215215

216-
fromValue = fromMayToValue (TString NoContext)
216+
fromValue = fromMayToValue $ TString NoContext
217217

218218

219219
newtype Path = Path { getPath :: FilePath }
@@ -414,16 +414,14 @@ instance (Convertible e t f m, ToValue a m (NValue t f m))
414414
instance Convertible e t f m
415415
=> ToValue NixLikeContextValue m (NValue' t f m (NValue t f m)) where
416416
toValue nlcv = do
417-
path <-
418-
bool
419-
(pure Nothing)
420-
(pure <$> toValue True)
421-
(nlcvPath nlcv)
422-
allOutputs <-
423-
bool
424-
(pure Nothing)
425-
(pure <$> toValue True)
426-
(nlcvAllOutputs nlcv)
417+
let
418+
g f =
419+
bool
420+
(pure Nothing)
421+
(pure <$> toValue True)
422+
(f nlcv)
423+
path <- g nlcvPath
424+
allOutputs <- g nlcvAllOutputs
427425
outputs <- do
428426
let
429427
outputs = makeNixStringWithoutContext <$> nlcvOutputs nlcv

src/Nix/Effects.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,18 @@ instance MonadExec IO where
144144
[] -> pure $ Left $ ErrorCall "exec: missing program"
145145
(prog : args) -> do
146146
(exitCode, out, _) <- liftIO $ readProcessWithExitCode (toString prog) (toString <$> args) ""
147-
let t = Text.strip $ toText out
148-
let emsg = "program[" <> prog <> "] args=" <> show args
147+
let
148+
t = Text.strip $ toText out
149+
emsg = "program[" <> prog <> "] args=" <> show args
149150
case exitCode of
150151
ExitSuccess ->
152+
pure $
151153
if Text.null t
152-
then pure $ Left $ ErrorCall $ toString $ "exec has no output :" <> emsg
154+
then Left $ ErrorCall $ toString $ "exec has no output :" <> emsg
153155
else
154156
either
155-
(\ err -> pure $ Left $ ErrorCall $ toString $ "Error parsing output of exec: " <> show err <> " " <> emsg)
156-
(pure . pure)
157+
(\ err -> Left $ ErrorCall $ toString $ "Error parsing output of exec: " <> show err <> " " <> emsg)
158+
pure
157159
(parseNixTextLoc t)
158160
err -> pure $ Left $ ErrorCall $ toString $ "exec failed: " <> show err <> " " <> emsg
159161

src/Nix/String.hs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ instance Monoid NixLikeContextValue where
9393
-- | A monad for accumulating string context while producing a result string.
9494
newtype WithStringContextT m a =
9595
WithStringContextT
96-
(WriterT
97-
(S.HashSet StringContext)
98-
m
99-
a
100-
)
96+
(WriterT (S.HashSet StringContext) m a )
10197
deriving (Functor, Applicative, Monad, MonadTrans, MonadWriter (S.HashSet StringContext))
10298

10399
type WithStringContext = WithStringContextT Identity
@@ -143,7 +139,7 @@ makeNixString = NixString
143139

144140
-- | Returns True if the NixString has an associated context
145141
stringHasContext :: NixString -> Bool
146-
stringHasContext (NixString _ c) = not (null c)
142+
stringHasContext (NixString _ c) = not $ null c
147143

148144

149145
-- ** Getters
@@ -169,8 +165,7 @@ stringIgnoreContext (NixString s _) = s
169165
extractNixString :: Monad m => NixString -> WithStringContextT m Text
170166
extractNixString (NixString s c) =
171167
WithStringContextT $
172-
tell c $>
173-
s
168+
s <$ tell c
174169

175170

176171
-- ** Setters
@@ -189,7 +184,7 @@ toStringContexts ~(path, nlcv) =
189184
NixLikeContextValue _ True _ ->
190185
mkLstCtxFor AllOutputs cv { nlcvAllOutputs = False }
191186
NixLikeContextValue _ _ ls | not (null ls) ->
192-
fmap (mkCtxFor . DerivationOutput) ls
187+
mkCtxFor . DerivationOutput <$> ls
193188
_ -> mempty
194189
where
195190
mkCtxFor = StringContext path
@@ -256,7 +251,7 @@ intercalateNixString :: NixString -> [NixString] -> NixString
256251
intercalateNixString _ [] = mempty
257252
intercalateNixString _ [ns] = ns
258253
intercalateNixString sep nss =
259-
uncurry NixString (mapPair intertwine unpackNss)
254+
uncurry NixString $ mapPair intertwine unpackNss
260255
where
261256

262257
intertwine =

src/Nix/Type/Env.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ merge :: Env -> Env -> Env
5959
merge (TypeEnv a) (TypeEnv b) = TypeEnv $ a `Map.union` b
6060

6161
mergeEnvs :: [Env] -> Env
62-
mergeEnvs = foldl' merge empty
62+
mergeEnvs = foldl' (<>) mempty
6363

6464
singleton :: Name -> Scheme -> Env
6565
singleton x y = TypeEnv $ one (x, [y])

0 commit comments

Comments
 (0)