Skip to content

Commit

Permalink
Effects.Basic: m refactor
Browse files Browse the repository at this point in the history
This may look obnoxious currently, but this is a process of moving the `tryPath`
to have it only once. But this form would allow to easily replace `demand` here
during #850, and the structure would
fold alpha convert simplify quite drastically.
  • Loading branch information
Anton-Latukha committed Mar 4, 2021
1 parent 3e0b84f commit 904bfca
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/Nix/Effects/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,26 @@ findPathBy finder ls name = do
demand
(\ nvpath ->
do
(Path path) <- fromValue nvpath
maybe
(tryPath path mempty)
(demand
(\ nvmns ->
do
mns <- fromValueMay nvmns
tryPath path $
case mns of
Just (nsPfx :: NixString) ->
let pfx = stringIgnoreContext nsPfx in
bool
mempty
(pure (Text.unpack pfx))
(not $ Text.null pfx)
_ -> mempty
(Path path) <- fromValue nvpath

maybe
(tryPath path mempty)
(demand
(\ nvmns ->
do
mns <- fromValueMay nvmns
tryPath path $
case mns of
Just (nsPfx :: NixString) ->
let pfx = stringIgnoreContext nsPfx in
bool
mempty
(pure (Text.unpack pfx))
(not $ Text.null pfx)
_ -> mempty
)
)
)
(M.lookup "prefix" s)
(M.lookup "prefix" s)
)
p
)
Expand Down

0 comments on commit 904bfca

Please sign in to comment.