]> git.immae.eu Git - github/fretlink/purs-loader.git/blob - src/PursLoader/Plugin.purs
Handle optional bundling by the compiler
[github/fretlink/purs-loader.git] / src / PursLoader / Plugin.purs
1 module PursLoader.Plugin
2 ( Result()
3 , Compile()
4 , Context()
5 , Options()
6 , ImmutableMap()
7 , DependencyGraph()
8 , get
9 , dependenciesOf
10 ) where
11
12 import Prelude (Unit())
13
14 import Control.Monad.Eff (Eff())
15 import Control.Monad.Eff.Exception (Error())
16
17 import Data.Either (Either(..))
18 import Data.Function (Fn4(), runFn4)
19 import Data.Maybe (Maybe(..))
20 import Data.Nullable (Nullable())
21
22 type Result = { srcMap :: ImmutableMap String String, ffiMap :: ImmutableMap String String, graph :: DependencyGraph }
23
24 type Compile eff = Nullable Error -> Result -> Eff eff Unit
25
26 type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options }
27
28 type Options = { bundle :: Boolean, output :: String, bundleOutput :: String }
29
30 get :: forall key value. ImmutableMap key value -> key -> Maybe value
31 get = runFn4 getFn Nothing Just
32
33 dependenciesOf :: DependencyGraph -> String -> Either Error (Array String)
34 dependenciesOf = runFn4 dependenciesOfFn Left Right
35
36 foreign import data ImmutableMap :: * -> * -> *
37
38 foreign import data DependencyGraph :: *
39
40 foreign import getFn
41 :: forall key value. Fn4 (Maybe value)
42 (value -> Maybe value)
43 (ImmutableMap key value)
44 key
45 (Maybe value)
46
47 foreign import dependenciesOfFn
48 :: Fn4 (Error -> Either Error (Array String))
49 (Array String -> Either Error (Array String))
50 DependencyGraph
51 String
52 (Either Error (Array String))