aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/FS.purs
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2015-07-06 23:49:47 -0400
committereric thul <thul.eric@gmail.com>2015-07-06 23:55:06 -0400
commit0e1221d7b15e578d5e9146b01e11a24007d4ba9b (patch)
treeaa70df70f6c36b7a85783c28d7eb256854b4232c /src/FS.purs
parentbc4de0853bd1cbf63842b3b66bb30494c9ea778a (diff)
downloadpurs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.tar.gz
purs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.tar.zst
purs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.zip
Generate .psci file
Resolves #11
Diffstat (limited to 'src/FS.purs')
-rw-r--r--src/FS.purs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/FS.purs b/src/FS.purs
new file mode 100644
index 0000000..a56fe26
--- /dev/null
+++ b/src/FS.purs
@@ -0,0 +1,32 @@
1module PursLoader.FS
2 ( FS()
3 , writeFileUtf8
4 ) where
5
6import Control.Monad.Aff (Aff(), makeAff)
7import Control.Monad.Eff (Eff())
8import Control.Monad.Eff.Exception (Error())
9
10import Data.Function
11
12foreign import data FS :: !
13
14writeFileUtf8 :: forall eff. String -> String -> Aff (fs :: FS | eff) Unit
15writeFileUtf8 filepath contents = makeAff $ runFn4 writeFileUtf8Fn filepath contents
16
17foreign import writeFileUtf8Fn """
18function writeFileUtf8Fn(filepath, contents, errback, callback) {
19 return function(){
20 var fs = require('fs');
21
22 fs.writeFile(filepath, contents, function(error){
23 if (error) errback(error)();
24 else callback()();
25 });
26 };
27}
28""" :: forall eff. Fn4 String
29 String
30 (Error -> Eff (fs :: FS | eff) Unit)
31 (Unit -> Eff (fs :: FS | eff) Unit)
32 (Eff (fs :: FS | eff) Unit)