Skip to content

Commit f25a579

Browse files
committed
Main: clean-up
1 parent 18f2e08 commit f25a579

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

main/Main.hs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,25 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
204204
where
205205
go :: Text -> AttrSet StdVal -> StdIO
206206
go prefix s =
207-
do
208-
xs <-
209-
traverse
207+
traverse_
208+
(\ (k, mv) ->
209+
do
210+
let
211+
path = prefix <> k
212+
(report, descend) = filterEntry path k
213+
when report $
214+
do
215+
liftIO $ Text.putStrLn path
216+
when descend $
217+
maybe
218+
stub
219+
(\case
220+
NVSet _ s' -> go (path <> ".") s'
221+
_ -> stub
222+
)
223+
mv
224+
)
225+
=<< traverse
210226
(\ (k, nv) ->
211227
(k, ) <$>
212228
free
@@ -221,7 +237,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
221237
(pure Nothing)
222238
(forceEntry path nv)
223239
(descend &&
224-
deferred
240+
deferred
225241
(const False)
226242
(const True)
227243
val
@@ -231,25 +247,6 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
231247
nv
232248
)
233249
(sortWith fst $ M.toList $ M.mapKeys coerce s)
234-
traverse_
235-
(\ (k, mv) ->
236-
do
237-
let
238-
path = prefix <> k
239-
(report, descend) = filterEntry path k
240-
when report $
241-
do
242-
liftIO $ Text.putStrLn path
243-
when descend $
244-
maybe
245-
stub
246-
(\case
247-
NVSet _ s' -> go (path <> ".") s'
248-
_ -> stub
249-
)
250-
mv
251-
)
252-
xs
253250
where
254251
filterEntry path k = case (path, k) of
255252
("stdenv", "stdenv" ) -> (True , True )
@@ -276,29 +273,30 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
276273
forceEntry k v =
277274
catch
278275
(pure <$> demand v)
279-
(\ (NixException frames) ->
280-
do
281-
liftIO
282-
. Text.putStrLn
283-
. (("Exception forcing " <> k <> ": ") <>)
284-
. show =<<
285-
renderFrames
286-
@(StdValue (StandardT (StdIdT IO)))
287-
@(StdThunk (StandardT (StdIdT IO)))
288-
frames
289-
pure Nothing
290-
)
276+
fun
277+
where
278+
fun :: NixException -> StandardIO (Maybe a)
279+
fun (coerce -> frames) =
280+
do
281+
liftIO
282+
. Text.putStrLn
283+
. (("Exception forcing " <> k <> ": ") <>)
284+
. show =<<
285+
renderFrames
286+
@StdVal
287+
@StdThun
288+
frames
289+
pure Nothing
291290

292291
reduction path mpathToContext annExpr =
293292
do
294293
eres <-
295294
withNixContext
296295
mpathToContext
297-
(reducingEvalExpr
298-
evalContent
299-
mpathToContext
300-
annExpr
301-
)
296+
$ reducingEvalExpr
297+
evalContent
298+
mpathToContext
299+
annExpr
302300
handleReduced path eres
303301

304302
handleReduced

0 commit comments

Comments
 (0)