diff options
author | eric <thul.eric@gmail.com> | 2015-04-12 11:35:25 -0400 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2015-04-12 11:35:25 -0400 |
commit | 7d58cf78c770ef95858f90c6e89bd18653657a82 (patch) | |
tree | ebae7549b1a1b14e11fd5e2ad4dd66d901af81c8 /src/Glob.purs | |
parent | 18ced1e0f031df444a5d85d72cd6843d826fef38 (diff) | |
parent | 94a23e744896b4440794de5d6cffedff1a1a2d56 (diff) | |
download | purs-loader-7d58cf78c770ef95858f90c6e89bd18653657a82.tar.gz purs-loader-7d58cf78c770ef95858f90c6e89bd18653657a82.tar.zst purs-loader-7d58cf78c770ef95858f90c6e89bd18653657a82.zip |
Merge pull request #8 from ethul/topic/purescript-rewrite
Topic/purescript rewrite
Diffstat (limited to 'src/Glob.purs')
-rw-r--r-- | src/Glob.purs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Glob.purs b/src/Glob.purs new file mode 100644 index 0000000..7bc9212 --- /dev/null +++ b/src/Glob.purs | |||
@@ -0,0 +1,31 @@ | |||
1 | module PursLoader.Glob | ||
2 | ( Glob() | ||
3 | , glob | ||
4 | ) where | ||
5 | |||
6 | import Control.Monad.Aff (Aff(), makeAff) | ||
7 | import Control.Monad.Eff (Eff()) | ||
8 | import Control.Monad.Eff.Exception (Error()) | ||
9 | |||
10 | import Data.Function | ||
11 | |||
12 | foreign import data Glob :: ! | ||
13 | |||
14 | glob :: forall eff. String -> Aff (glob :: Glob | eff) [String] | ||
15 | glob pattern = makeAff $ runFn3 globFn pattern | ||
16 | |||
17 | foreign import globFn """ | ||
18 | function globFn(pattern, errback, callback) { | ||
19 | return function(){ | ||
20 | var glob = require('glob'); | ||
21 | |||
22 | glob(pattern, function(e, data){ | ||
23 | if (e) errback(e)(); | ||
24 | else callback(data)(); | ||
25 | }); | ||
26 | }; | ||
27 | } | ||
28 | """ :: forall eff. Fn3 String | ||
29 | (Error -> Eff (glob :: Glob | eff) Unit) | ||
30 | ([String] -> Eff (glob :: Glob | eff) Unit) | ||
31 | (Eff (glob :: Glob | eff) Unit) | ||