1
1
mirror of https://github.com/nmattia/snack.git synced 2024-12-11 11:04:03 +03:00

Fix tree too shallow bug

This commit is contained in:
Nicolas Mattia 2018-06-22 19:16:31 +02:00
parent 30b4af80e0
commit c71f16657d
3 changed files with 21 additions and 18 deletions

View File

@ -97,27 +97,24 @@ let
# Returns an attribute set where the keys are the module names and the values
# are the '.o's
flattenModuleObjects = ghcWith: mod0:
let
go = mod: attrs0:
let
objectName = x:
lib.fix (f: acc: mod:
let objectName = x:
# TODO: can't justuse "moduleName.o" because some modules get
# renamed to "Main.o" :/ Also, hard coding the object file based on
# the module name feels icky
if x.moduleIsMain
then "Main.o"
else moduleToObject x.moduleName;
attrs1 = f attrs0 mod;
f = acc: elem:
if lib.attrsets.hasAttr elem.moduleName acc
then acc # breaks infinite recursion
else acc //
{ "${elem.moduleName}" =
"${buildModule ghcWith elem}/${objectName elem}";
};
in
lib.lists.foldl f attrs1 mod.moduleImports;
in go mod0 {};
in
if lib.attrsets.hasAttr mod.moduleName acc
then acc
else
let acc' = acc //
{ "${mod.moduleName}" =
"${buildModule ghcWith mod}/${objectName mod}";
};
in lib.foldl f acc' mod.moduleImports
) {} mod0;
linkModuleObjects = ghcWith: mod: # main module
let

7
tests/library/app/Bar.hs Normal file
View File

@ -0,0 +1,7 @@
module Bar where
import Conduit
import FooBar
main :: IO ()
main = runConduit $ spitOut .| takeC 5 .| digest

View File

@ -1,5 +1,4 @@
import Conduit
import FooBar
import qualified Bar
main :: IO ()
main = runConduit $ spitOut .| takeC 5 .| digest
main = Bar.main