Skip to content

Commit fc15ee6

Browse files
committed
Lint: m refactor
1 parent 5d4af88 commit fc15ee6

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Nix/Lint.hs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ merge context = go
203203
)
204204
(pure <$> l)
205205
(pure <$> r)
206-
if M.null m then go xs ys else (TSet (pure m) :) <$> go xs ys
206+
bool
207+
id
208+
((TSet (pure m) :) <$>)
209+
(not $ M.null m)
210+
(go xs ys)
211+
207212
(TClosure{}, TClosure{}) ->
208213
throwError $ ErrorCall "Cannot unify functions"
209214
(TBuiltin _ _, TBuiltin _ _) ->
@@ -301,19 +306,9 @@ instance (MonadThunkId m, MonadAtomicRef m, MonadCatch m)
301306
instance MonadLint e m => MonadEval (Symbolic m) m where
302307
freeVariable var = symerr $ "Undefined variable '" <> Text.unpack var <> "'"
303308

304-
attrMissing ks Nothing =
305-
evalError @(Symbolic m)
306-
$ ErrorCall
307-
$ "Inheriting unknown attribute: "
308-
<> intercalate "." (fmap Text.unpack (NE.toList ks))
309+
attrMissing ks Nothing = evalError @(Symbolic m) $ ErrorCall $ "Inheriting unknown attribute: " <> intercalate "." (fmap Text.unpack (NE.toList ks))
309310

310-
attrMissing ks (Just s) =
311-
evalError @(Symbolic m)
312-
$ ErrorCall
313-
$ "Could not look up attribute "
314-
<> intercalate "." (fmap Text.unpack (NE.toList ks))
315-
<> " in "
316-
<> show s
311+
attrMissing ks (Just s) = evalError @(Symbolic m) $ ErrorCall $ "Could not look up attribute " <> intercalate "." (fmap Text.unpack (NE.toList ks)) <> " in " <> show s
317312

318313
evalCurPos = do
319314
f <- mkSymbolic [TPath]
@@ -353,7 +348,8 @@ instance MonadLint e m => MonadEval (Symbolic m) m where
353348
(unpackSymbolic >=> \case
354349
NMany [TSet (Just s')] -> pure s'
355350
NMany [TSet Nothing] -> error "NYI: with unknown"
356-
_ -> throwError $ ErrorCall "scope must be a set in with statement")
351+
_ -> throwError $ ErrorCall "scope must be a set in with statement"
352+
)
357353
s
358354

359355
evalIf cond t f = do

0 commit comments

Comments
 (0)