blob: a56fe263379923733c7303e8684e8ef7f9874dda (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
module PursLoader.FS
( FS()
, writeFileUtf8
) where
import Control.Monad.Aff (Aff(), makeAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (Error())
import Data.Function
foreign import data FS :: !
writeFileUtf8 :: forall eff. String -> String -> Aff (fs :: FS | eff) Unit
writeFileUtf8 filepath contents = makeAff $ runFn4 writeFileUtf8Fn filepath contents
foreign import writeFileUtf8Fn """
function writeFileUtf8Fn(filepath, contents, errback, callback) {
return function(){
var fs = require('fs');
fs.writeFile(filepath, contents, function(error){
if (error) errback(error)();
else callback()();
});
};
}
""" :: forall eff. Fn4 String
String
(Error -> Eff (fs :: FS | eff) Unit)
(Unit -> Eff (fs :: FS | eff) Unit)
(Eff (fs :: FS | eff) Unit)
|