aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/LoaderRef.purs
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2015-08-11 20:57:07 -0400
committereric thul <thul.eric@gmail.com>2015-08-11 20:57:07 -0400
commit03b840cb5fb8ff5217fefc9e1240a3131db309fc (patch)
tree6183f4453aa15ad67ee0249fb8d35702cef5ecad /src/PursLoader/LoaderRef.purs
parentfa01c5a4cb42d80ac147dc5ab512a0795dbe14da (diff)
downloadpurs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.tar.gz
purs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.tar.zst
purs-loader-03b840cb5fb8ff5217fefc9e1240a3131db309fc.zip
PureScript 0.7 updates and migration to pulp
Diffstat (limited to 'src/PursLoader/LoaderRef.purs')
-rw-r--r--src/PursLoader/LoaderRef.purs56
1 files changed, 11 insertions, 45 deletions
diff --git a/src/PursLoader/LoaderRef.purs b/src/PursLoader/LoaderRef.purs
index f1efa04..33c4f7e 100644
--- a/src/PursLoader/LoaderRef.purs
+++ b/src/PursLoader/LoaderRef.purs
@@ -9,6 +9,8 @@ module PursLoader.LoaderRef
9 , resourcePath 9 , resourcePath
10 ) where 10 ) where
11 11
12import Prelude (Unit())
13
12import Control.Monad.Eff (Eff()) 14import Control.Monad.Eff (Eff())
13import Control.Monad.Eff.Exception (Error()) 15import Control.Monad.Eff.Exception (Error())
14 16
@@ -19,56 +21,20 @@ data LoaderRef
19 21
20foreign import data Loader :: ! 22foreign import data Loader :: !
21 23
22foreign import asyncFn """ 24foreign import asyncFn :: forall eff a. Fn3 (Maybe Error -> Boolean)
23function asyncFn(isJust, fromMaybe, ref){ 25 (Error -> Maybe Error -> Error)
24 return function(){ 26 LoaderRef
25 var callback = ref.async(); 27 (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
26 return function(error){
27 return function(value){
28 return function(){
29 return isJust(error) ? callback(fromMaybe(new Error())(error))
30 : callback(null, value);
31 };
32 };
33 };
34 };
35}""" :: forall eff a. Fn3 (Maybe Error -> Boolean)
36 (Error -> Maybe Error -> Error)
37 LoaderRef
38 (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
39 28
40async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit) 29async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
41async ref = runFn3 asyncFn isJust fromMaybe ref 30async ref = runFn3 asyncFn isJust fromMaybe ref
42 31
43foreign import cacheable """ 32foreign import cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
44function cacheable(ref){
45 return function(){
46 return ref.cacheable && ref.cacheable();
47 };
48}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
49 33
50foreign import query """ 34foreign import query :: LoaderRef -> String
51function query(ref){
52 return ref.query;
53}""" :: LoaderRef -> String
54 35
55foreign import clearDependencies """ 36foreign import clearDependencies :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
56function clearDependencies(ref){
57 return function(){
58 return ref.clearDependencies();
59 };
60}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
61 37
62foreign import resourcePath """ 38foreign import resourcePath :: LoaderRef -> String
63function resourcePath(ref){
64 return ref.resourcePath;
65}""" :: LoaderRef -> String
66 39
67foreign import addDependency """ 40foreign import addDependency :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit
68function addDependency(ref){
69 return function(dep){
70 return function(){
71 return ref.addDependency(dep);
72 };
73 };
74}""" :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit