From 460393439a8dd7d94fe02a2013e96c9146282bf1 Mon Sep 17 00:00:00 2001 From: eric thul Date: Wed, 24 Feb 2016 22:53:40 -0500 Subject: 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 --- src/PursLoader/Plugin.purs | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/PursLoader/Plugin.purs (limited to 'src/PursLoader/Plugin.purs') 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 @@ +module PursLoader.Plugin + ( Result() + , Compile() + , Context() + , ImmutableMap() + , DependencyGraph() + , get + , dependenciesOf + ) where + +import Prelude (Unit()) + +import Control.Monad.Eff (Eff()) +import Control.Monad.Eff.Exception (Error()) + +import Data.Either (Either(..)) +import Data.Function (Fn4(), runFn4) +import Data.Maybe (Maybe(..)) +import Data.Nullable (Nullable()) + +type Result = { srcMap :: ImmutableMap String String, ffiMap :: ImmutableMap String String, graph :: DependencyGraph } + +type Compile eff = Nullable Error -> Result -> Eff eff Unit + +type Context eff = { compile :: Compile eff -> Eff eff Unit } + +get :: forall key value. ImmutableMap key value -> key -> Maybe value +get = runFn4 getFn Nothing Just + +dependenciesOf :: DependencyGraph -> String -> Either Error (Array String) +dependenciesOf = runFn4 dependenciesOfFn Left Right + +foreign import data ImmutableMap :: * -> * -> * + +foreign import data DependencyGraph :: * + +foreign import getFn + :: forall key value. Fn4 (Maybe value) + (value -> Maybe value) + (ImmutableMap key value) + key + (Maybe value) + +foreign import dependenciesOfFn + :: Fn4 (Error -> Either Error (Array String)) + (Array String -> Either Error (Array String)) + DependencyGraph + String + (Either Error (Array String)) -- cgit v1.2.3