diff options
Diffstat (limited to 'src/FS.purs')
-rw-r--r-- | src/FS.purs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/FS.purs b/src/FS.purs deleted file mode 100644 index 68fe2f9..0000000 --- a/src/FS.purs +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | module PursLoader.FS | ||
2 | ( FS() | ||
3 | , readFileUtf8 | ||
4 | , readFileUtf8Sync | ||
5 | ) where | ||
6 | |||
7 | import Control.Monad.Aff (Aff(), makeAff) | ||
8 | import Control.Monad.Eff (Eff()) | ||
9 | import Control.Monad.Eff.Exception (Error()) | ||
10 | |||
11 | import Data.Function | ||
12 | |||
13 | foreign import data FS :: ! | ||
14 | |||
15 | readFileUtf8 :: forall eff. String -> Aff (fs :: FS | eff) String | ||
16 | readFileUtf8 filepath = makeAff $ runFn3 readFileUtf8Fn filepath | ||
17 | |||
18 | readFileUtf8Sync :: forall eff. String -> Eff (fs :: FS | eff) String | ||
19 | readFileUtf8Sync filepath = readFileUtf8SyncFn filepath | ||
20 | |||
21 | foreign import readFileUtf8Fn """ | ||
22 | function readFileUtf8Fn(filepath, errback, callback) { | ||
23 | return function(){ | ||
24 | var fs = require('fs'); | ||
25 | |||
26 | fs.readFile(filepath, 'utf-8', function(e, data){ | ||
27 | if (e) errback(e)(); | ||
28 | else callback(data)(); | ||
29 | }); | ||
30 | }; | ||
31 | } | ||
32 | """ :: forall eff. Fn3 String | ||
33 | (Error -> Eff (fs :: FS | eff) Unit) | ||
34 | (String -> Eff (fs :: FS | eff) Unit) | ||
35 | (Eff (fs :: FS | eff) Unit) | ||
36 | |||
37 | foreign import readFileUtf8SyncFn """ | ||
38 | function readFileUtf8SyncFn(filepath) { | ||
39 | return function(){ | ||
40 | var fs = require('fs'); | ||
41 | |||
42 | return fs.readFileSync(filepath, {encoding: 'utf-8'}); | ||
43 | }; | ||
44 | } | ||
45 | """ :: forall eff. String -> (Eff (fs :: FS | eff) String) | ||