aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/Plugin.purs
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-02-24 22:53:40 -0500
committereric thul <thul.eric@gmail.com>2016-02-24 22:53:40 -0500
commit460393439a8dd7d94fe02a2013e96c9146282bf1 (patch)
tree178492f39cc5afa716f1c403d4a28d45606336a3 /src/PursLoader/Plugin.purs
parentef1525b5a0fe3f4561493aaca49907dba827dbd6 (diff)
downloadpurs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.gz
purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.zst
purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.zip
Adds dependencies of modules process by the loader.
The module file path and dependency graph information is provided by the purescript-webpack-plugin. Resolves #37
Diffstat (limited to 'src/PursLoader/Plugin.purs')
-rw-r--r--src/PursLoader/Plugin.purs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/PursLoader/Plugin.purs b/src/PursLoader/Plugin.purs
new file mode 100644
index 0000000..23f8600
--- /dev/null
+++ b/src/PursLoader/Plugin.purs
@@ -0,0 +1,49 @@
1module PursLoader.Plugin
2 ( Result()
3 , Compile()
4 , Context()
5 , ImmutableMap()
6 , DependencyGraph()
7 , get
8 , dependenciesOf
9 ) where
10
11import Prelude (Unit())
12
13import Control.Monad.Eff (Eff())
14import Control.Monad.Eff.Exception (Error())
15
16import Data.Either (Either(..))
17import Data.Function (Fn4(), runFn4)
18import Data.Maybe (Maybe(..))
19import Data.Nullable (Nullable())
20
21type Result = { srcMap :: ImmutableMap String String, ffiMap :: ImmutableMap String String, graph :: DependencyGraph }
22
23type Compile eff = Nullable Error -> Result -> Eff eff Unit
24
25type Context eff = { compile :: Compile eff -> Eff eff Unit }
26
27get :: forall key value. ImmutableMap key value -> key -> Maybe value
28get = runFn4 getFn Nothing Just
29
30dependenciesOf :: DependencyGraph -> String -> Either Error (Array String)
31dependenciesOf = runFn4 dependenciesOfFn Left Right
32
33foreign import data ImmutableMap :: * -> * -> *
34
35foreign import data DependencyGraph :: *
36
37foreign import getFn
38 :: forall key value. Fn4 (Maybe value)
39 (value -> Maybe value)
40 (ImmutableMap key value)
41 key
42 (Maybe value)
43
44foreign import dependenciesOfFn
45 :: Fn4 (Error -> Either Error (Array String))
46 (Array String -> Either Error (Array String))
47 DependencyGraph
48 String
49 (Either Error (Array String))