Skip to content

Commit 1e8c6b5

Browse files
committed
Small tweak to 'go'
1 parent 0523545 commit 1e8c6b5

File tree

2 files changed

+29
-56
lines changed

2 files changed

+29
-56
lines changed

js/index.js

Lines changed: 21 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Try/Loader.purs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ runLoader :: Loader -> JS -> ExceptT String (ContT Unit Effect) (Object JS)
7373
runLoader (Loader k) = k
7474

7575
makeLoader :: (Module -> Module) -> String -> Loader
76-
makeLoader modFn rootPath = Loader \js -> do
77-
let initDeps = parseDeps "<file>" js
78-
go initDeps Object.empty
76+
makeLoader modFn rootPath = Loader (go Object.empty <<< parseDeps "<file>")
7977
where
8078
moduleCache :: Ref (Object Module)
8179
moduleCache = unsafePerformEffect (Ref.new Object.empty)
@@ -97,19 +95,17 @@ makeLoader modFn rootPath = Loader \js -> do
9795
liftEffect $ putModule name mod
9896
pure mod
9997

100-
go :: Array Dependency -> Object JS -> ExceptT String (ContT Unit Effect) (Object JS)
101-
go deps accum = do
98+
go :: Object JS -> Array Dependency -> ExceptT String (ContT Unit Effect) (Object JS)
99+
go accum [] = pure accum
100+
go accum deps = do
102101
modules <- parTraverse load deps
103102
let
104103
accum' =
105104
modules
106105
# map (\{ name, src } -> Tuple name src)
107106
# Object.fromFoldable
108107
# Object.union accum
109-
more =
110-
modules
111-
# bindFlipped _.deps
112-
# Array.nubBy (comparing _.name)
113-
case more of
114-
[] -> pure accum'
115-
_ -> go more accum'
108+
modules
109+
# bindFlipped _.deps
110+
# Array.nubBy (comparing _.name)
111+
# go accum'

0 commit comments

Comments
 (0)