diff options
author | eric <thul.eric@gmail.com> | 2016-02-25 21:48:42 -0500 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2016-02-25 21:48:42 -0500 |
commit | d7d4ec32989320d0fb62413d59b137279824de5b (patch) | |
tree | 2ab19c4a3f01925f1ee5c29f99c4f6cd6e5c1166 /src/PursLoader/Plugin.purs | |
parent | ef1525b5a0fe3f4561493aaca49907dba827dbd6 (diff) | |
parent | f97818b550b17455448ff7fe09689b326c30912b (diff) | |
download | purs-loader-d7d4ec32989320d0fb62413d59b137279824de5b.tar.gz purs-loader-d7d4ec32989320d0fb62413d59b137279824de5b.tar.zst purs-loader-d7d4ec32989320d0fb62413d59b137279824de5b.zip |
Merge pull request #38 from ethul/topic/dependency-graph
Topic/dependency graph
Diffstat (limited to 'src/PursLoader/Plugin.purs')
-rw-r--r-- | src/PursLoader/Plugin.purs | 49 |
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 @@ | |||
1 | module PursLoader.Plugin | ||
2 | ( Result() | ||
3 | , Compile() | ||
4 | , Context() | ||
5 | , ImmutableMap() | ||
6 | , DependencyGraph() | ||
7 | , get | ||
8 | , dependenciesOf | ||
9 | ) where | ||
10 | |||
11 | import Prelude (Unit()) | ||
12 | |||
13 | import Control.Monad.Eff (Eff()) | ||
14 | import Control.Monad.Eff.Exception (Error()) | ||
15 | |||
16 | import Data.Either (Either(..)) | ||
17 | import Data.Function (Fn4(), runFn4) | ||
18 | import Data.Maybe (Maybe(..)) | ||
19 | import Data.Nullable (Nullable()) | ||
20 | |||
21 | type Result = { srcMap :: ImmutableMap String String, ffiMap :: ImmutableMap String String, graph :: DependencyGraph } | ||
22 | |||
23 | type Compile eff = Nullable Error -> Result -> Eff eff Unit | ||
24 | |||
25 | type Context eff = { compile :: Compile eff -> Eff eff Unit } | ||
26 | |||
27 | get :: forall key value. ImmutableMap key value -> key -> Maybe value | ||
28 | get = runFn4 getFn Nothing Just | ||
29 | |||
30 | dependenciesOf :: DependencyGraph -> String -> Either Error (Array String) | ||
31 | dependenciesOf = runFn4 dependenciesOfFn Left Right | ||
32 | |||
33 | foreign import data ImmutableMap :: * -> * -> * | ||
34 | |||
35 | foreign import data DependencyGraph :: * | ||
36 | |||
37 | foreign import getFn | ||
38 | :: forall key value. Fn4 (Maybe value) | ||
39 | (value -> Maybe value) | ||
40 | (ImmutableMap key value) | ||
41 | key | ||
42 | (Maybe value) | ||
43 | |||
44 | foreign 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)) | ||