From 1983893bf09a5c2ea1946e156be5da170075af7e Mon Sep 17 00:00:00 2001 From: eric thul Date: Sun, 5 Jul 2015 10:13:47 -0400 Subject: Updating for PureScript 0.7 Resolves #14 --- src/FS.purs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/FS.purs (limited to 'src/FS.purs') 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 @@ -module PursLoader.FS - ( FS() - , readFileUtf8 - , readFileUtf8Sync - ) 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 :: ! - -readFileUtf8 :: forall eff. String -> Aff (fs :: FS | eff) String -readFileUtf8 filepath = makeAff $ runFn3 readFileUtf8Fn filepath - -readFileUtf8Sync :: forall eff. String -> Eff (fs :: FS | eff) String -readFileUtf8Sync filepath = readFileUtf8SyncFn filepath - -foreign import readFileUtf8Fn """ -function readFileUtf8Fn(filepath, errback, callback) { - return function(){ - var fs = require('fs'); - - fs.readFile(filepath, 'utf-8', function(e, data){ - if (e) errback(e)(); - else callback(data)(); - }); - }; -} -""" :: forall eff. Fn3 String - (Error -> Eff (fs :: FS | eff) Unit) - (String -> Eff (fs :: FS | eff) Unit) - (Eff (fs :: FS | eff) Unit) - -foreign import readFileUtf8SyncFn """ -function readFileUtf8SyncFn(filepath) { - return function(){ - var fs = require('fs'); - - return fs.readFileSync(filepath, {encoding: 'utf-8'}); - }; -} -""" :: forall eff. String -> (Eff (fs :: FS | eff) String) -- cgit v1.2.3 From 0e1221d7b15e578d5e9146b01e11a24007d4ba9b Mon Sep 17 00:00:00 2001 From: eric thul Date: Mon, 6 Jul 2015 23:49:47 -0400 Subject: Generate .psci file Resolves #11 --- src/FS.purs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/FS.purs (limited to 'src/FS.purs') 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 @@ +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) -- cgit v1.2.3