+++ /dev/null
-# Module Documentation
-
-## Module PursLoader.ChildProcess
-
-#### `ChildProcess`
-
-``` purescript
-data ChildProcess :: !
-```
-
-
-#### `spawn`
-
-``` purescript
-spawn :: forall eff. String -> [String] -> Aff (cp :: ChildProcess | eff) String
-```
-
-
-
-## Module PursLoader.FS
-
-#### `FS`
-
-``` purescript
-data FS :: !
-```
-
-
-#### `writeFileUtf8`
-
-``` purescript
-writeFileUtf8 :: forall eff. String -> String -> Aff (fs :: FS | eff) Unit
-```
-
-
-
-## Module PursLoader.Glob
-
-#### `Glob`
-
-``` purescript
-data Glob :: !
-```
-
-
-#### `globAll`
-
-``` purescript
-globAll :: forall eff. [String] -> Aff (glob :: Glob | eff) [[String]]
-```
-
-
-
-## Module PursLoader.Loader
-
-#### `Effects`
-
-``` purescript
-type Effects eff = (loader :: Loader, glob :: Glob, fs :: FS, cp :: ChildProcess | eff)
-```
-
-
-#### `loader`
-
-``` purescript
-loader :: forall eff. LoaderRef -> String -> Eff (Effects eff) Unit
-```
-
-
-#### `loaderFn`
-
-``` purescript
-loaderFn :: forall eff. Fn2 LoaderRef String (Eff (Effects eff) Unit)
-```
-
-
-
-## Module PursLoader.LoaderRef
-
-#### `LoaderRef`
-
-``` purescript
-data LoaderRef
-```
-
-
-#### `Loader`
-
-``` purescript
-data Loader :: !
-```
-
-
-#### `async`
-
-``` purescript
-async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
-```
-
-
-#### `cacheable`
-
-``` purescript
-cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
-```
-
-
-#### `query`
-
-``` purescript
-query :: LoaderRef -> String
-```
-
-
-
-## Module PursLoader.LoaderUtil
-
-#### `parseQuery`
-
-``` purescript
-parseQuery :: String -> Foreign
-```
-
-
-
-## Module PursLoader.Options
-
-#### `isForeignOptions`
-
-``` purescript
-instance isForeignOptions :: IsForeign Options
-```
-
-
-#### `booleanLoaderOption`
-
-``` purescript
-instance booleanLoaderOption :: LoaderOption Boolean
-```
-
-
-#### `stringLoaderOption`
-
-``` purescript
-instance stringLoaderOption :: LoaderOption String
-```
-
-
-#### `arrayLoaderOption`
-
-``` purescript
-instance arrayLoaderOption :: (LoaderOption a) => LoaderOption [a]
-```
-
-
-#### `pscOptions`
-
-``` purescript
-pscOptions :: Foreign -> [String]
-```
-
-
-#### `loaderSrcOption`
-
-``` purescript
-loaderSrcOption :: Foreign -> Maybe [String]
-```
-
-
-#### `loaderFFIOption`
-
-``` purescript
-loaderFFIOption :: Foreign -> Maybe [String]
-```
-
-
-
-
"name": "purs-loader",
"private": true,
"devDependencies": {
- "purescript-aff": "~0.9.1",
- "purescript-exceptions": "~0.2.3",
- "purescript-strings": "~0.4.5",
- "purescript-maybe": "~0.2.2",
- "purescript-foreign": "~0.4.2",
- "purescript-foldable-traversable": "~0.3.1",
- "purescript-tuples": "~0.3.4",
- "purescript-maps": "~0.3.3",
- "purescript-arrays": "~0.3.7",
- "purescript-monad-eff": "~0.1.0",
- "purescript-sets": "0.3.2"
+ "purescript-aff": "~0.11.3",
+ "purescript-strings": "~0.6.0",
+ "purescript-foreign": "~0.6.0"
}
}
--- /dev/null
+## Module PursLoader.ChildProcess
+
+#### `ChildProcess`
+
+``` purescript
+data ChildProcess :: !
+```
+
+#### `spawn`
+
+``` purescript
+spawn :: forall eff. String -> Array String -> Aff (cp :: ChildProcess | eff) String
+```
+
+
--- /dev/null
+## Module PursLoader.FS
+
+#### `FS`
+
+``` purescript
+data FS :: !
+```
+
+#### `writeFileUtf8`
+
+``` purescript
+writeFileUtf8 :: forall eff. String -> String -> Aff (fs :: FS | eff) Unit
+```
+
+#### `findFileUtf8`
+
+``` purescript
+findFileUtf8 :: forall eff. Regex -> Array String -> Aff (fs :: FS | eff) (Maybe String)
+```
+
+
--- /dev/null
+## Module PursLoader.Glob
+
+#### `Glob`
+
+``` purescript
+data Glob :: !
+```
+
+#### `globAll`
+
+``` purescript
+globAll :: forall eff. Array String -> Aff (glob :: Glob | eff) (Array (Array String))
+```
+
+
--- /dev/null
+## Module PursLoader.Loader
+
+#### `Effects`
+
+``` purescript
+type Effects eff = (cp :: ChildProcess, fs :: FS, glob :: Glob, loader :: Loader | eff)
+```
+
+#### `loader`
+
+``` purescript
+loader :: forall eff. LoaderRef -> String -> Eff (Effects eff) Unit
+```
+
+#### `loaderFn`
+
+``` purescript
+loaderFn :: forall eff. Fn2 LoaderRef String (Eff (Effects eff) Unit)
+```
+
+
--- /dev/null
+## Module PursLoader.LoaderRef
+
+#### `LoaderRef`
+
+``` purescript
+data LoaderRef
+```
+
+#### `Loader`
+
+``` purescript
+data Loader :: !
+```
+
+#### `async`
+
+``` purescript
+async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
+```
+
+#### `cacheable`
+
+``` purescript
+cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
+```
+
+#### `query`
+
+``` purescript
+query :: LoaderRef -> String
+```
+
+#### `clearDependencies`
+
+``` purescript
+clearDependencies :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
+```
+
+#### `resourcePath`
+
+``` purescript
+resourcePath :: LoaderRef -> String
+```
+
+#### `addDependency`
+
+``` purescript
+addDependency :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit
+```
+
+
--- /dev/null
+## Module PursLoader.LoaderUtil
+
+#### `parseQuery`
+
+``` purescript
+parseQuery :: String -> Foreign
+```
+
+
--- /dev/null
+## Module PursLoader.Options
+
+#### `pscOptions`
+
+``` purescript
+pscOptions :: Foreign -> Array String
+```
+
+#### `loaderSrcOption`
+
+``` purescript
+loaderSrcOption :: Foreign -> Maybe (Array String)
+```
+
+#### `loaderFFIOption`
+
+``` purescript
+loaderFFIOption :: Foreign -> Maybe (Array String)
+```
+
+
"email": "thul.eric@gmail.com"
},
"scripts": {
- "build": "npm run-script build:compile && npm run-script build:package",
+ "build": "npm run-script build:compile && npm run-script build:docs && npm run-script build:package",
"build:compile": "./node_modules/.bin/pulp build -o build",
- "build:watch": "./node_modules/.bin/pulp -w build -o build",
+ "build:docs": "./node_modules/.bin/pulp docs",
"build:package": "./node_modules/.bin/webpack --progress --colors --profile --bail",
+ "build:watch": "./node_modules/.bin/pulp -w build -o build",
"build:json": "./node_modules/.bin/webpack --progress --colors --profile --bail --json > index.json",
"prepublish": "npm run-script build"
},
--- /dev/null
+'use strict';
+
+// module PursLoader.ChildProcess
+
+var child_process = require('child_process');
+
+var chalk = require('chalk');
+
+function spawnFn(command, args, errback, callback) {
+ return function(){
+ var process = child_process.spawn(command, args);
+
+ var stdout = new Buffer(0);
+
+ var stderr = new Buffer(0);
+
+ process.stdout.on('data', function(data){
+ stdout = Buffer.concat([stdout, new Buffer(data)]);
+ });
+
+ process.stderr.on('data', function(data){
+ stderr = Buffer.concat([stderr, new Buffer(data)]);
+ });
+
+ process.on('close', function(code){
+ var output = stdout.toString('utf-8');
+
+ var error = stderr.toString('utf-8');
+
+ if (error.length > 0) {
+ console.error('\n' + chalk.red('*') + ' ' + error);
+ }
+
+ if (code !== 0) errback(new Error('Process terminated with code ' + code))();
+ else callback(output)();
+ });
+ };
+}
+
+exports.spawnFn = spawnFn;
, spawn
) where
+import Prelude (Unit(), ($))
+
import Control.Monad.Aff (Aff(), makeAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (Error())
foreign import data ChildProcess :: !
-spawn :: forall eff. String -> [String] -> Aff (cp :: ChildProcess | eff) String
+spawn :: forall eff. String -> Array String -> Aff (cp :: ChildProcess | eff) String
spawn command args = makeAff $ runFn4 spawnFn command args
-foreign import spawnFn """
-function spawnFn(command, args, errback, callback) {
- return function(){
- var child_process = require('child_process');
-
- var process = child_process.spawn(command, args);
-
- var stdout = new Buffer(0);
-
- var stderr = new Buffer(0);
-
- process.stdout.on('data', function(data){
- stdout = Buffer.concat([stdout, new Buffer(data)]);
- });
-
- process.stderr.on('data', function(data){
- stderr = Buffer.concat([stderr, new Buffer(data)]);
- });
-
- process.on('close', function(code){
- var chalk = require('chalk');
-
- var output = stdout.toString('utf-8');
-
- var error = stderr.toString('utf-8');
-
- if (error.length > 0) {
- console.error('\n' + chalk.red('*') + ' ' + error);
- }
-
- if (code !== 0) errback(new Error('Process terminated with code ' + code))();
- else callback(output)();
- });
- };
-}
-""" :: forall eff. Fn4 String
- [String]
- (Error -> Eff (cp :: ChildProcess | eff) Unit)
- (String -> Eff (cp :: ChildProcess | eff) Unit)
- (Eff (cp :: ChildProcess | eff) Unit)
+foreign import spawnFn :: forall eff. Fn4 String
+ (Array String)
+ (Error -> Eff (cp :: ChildProcess | eff) Unit)
+ (String -> Eff (cp :: ChildProcess | eff) Unit)
+ (Eff (cp :: ChildProcess | eff) Unit)
--- /dev/null
+'use strict';
+
+// module PursLoader.FS
+
+var fs = require('fs');
+
+var async = require('async');
+
+function writeFileUtf8Fn(filepath, contents, errback, callback) {
+ return function(){
+ fs.writeFile(filepath, contents, function(error){
+ if (error) errback(error)();
+ else callback()();
+ });
+ };
+}
+
+function findFileUtf8Fn(nothing, just, regex, filepaths, errback, callback) {
+ return function(){
+ function findFile(filepath, callback) {
+ fs.readFile(filepath, {encoding: 'utf-8'}, function(error, result){
+ if (error) callback(false);
+ else callback(regex.test(result));
+ });
+ }
+
+ async.detect(filepaths, findFile, function(result){
+ if (!result) callback(nothing)();
+ else callback(just(result))();
+ });
+ };
+}
+
+exports.writeFileUtf8Fn = writeFileUtf8Fn;
+
+exports.findFileUtf8Fn = findFileUtf8Fn;
, findFileUtf8
) where
+import Prelude (Unit(), ($))
+
import Control.Monad.Aff (Aff(), makeAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (Error())
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)
+foreign import writeFileUtf8Fn :: forall eff. Fn4 String
+ String
+ (Error -> Eff (fs :: FS | eff) Unit)
+ (Unit -> Eff (fs :: FS | eff) Unit)
+ (Eff (fs :: FS | eff) Unit)
-findFileUtf8 :: forall eff. Regex -> [String] -> Aff (fs :: FS | eff) (Maybe String)
+findFileUtf8 :: forall eff. Regex -> Array String -> Aff (fs :: FS | eff) (Maybe String)
findFileUtf8 regexp filepaths = makeAff $ runFn6 findFileUtf8Fn Nothing Just regexp filepaths
-foreign import findFileUtf8Fn """
-function findFileUtf8Fn(nothing, just, regex, filepaths, errback, callback) {
- return function(){
- var fs = require('fs');
-
- var async = require('async');
-
- function findFile(filepath, callback) {
- fs.readFile(filepath, {encoding: 'utf-8'}, function(error, result){
- if (error) callback(false);
- else callback(regex.test(result));
- });
- }
-
- async.detect(filepaths, findFile, function(result){
- if (!result) callback(nothing)();
- else callback(just(result))();
- });
- };
-}
-""" :: forall eff. Fn6 (Maybe String)
- (String -> Maybe String)
- Regex
- [String]
- (Error -> Eff (fs :: FS | eff) Unit)
- (Maybe String -> Eff (fs :: FS | eff) Unit)
- (Eff (fs :: FS | eff) Unit)
+foreign import findFileUtf8Fn :: forall eff. Fn6 (Maybe String)
+ (String -> Maybe String)
+ Regex
+ (Array String)
+ (Error -> Eff (fs :: FS | eff) Unit)
+ (Maybe String -> Eff (fs :: FS | eff) Unit)
+ (Eff (fs :: FS | eff) Unit)
--- /dev/null
+'use strict';
+
+// module PursLoader.Glob
+
+var glob = require('glob');
+
+var async = require('async');
+
+function globAllFn(patterns, errback, callback) {
+ return function(){
+ async.map(patterns, glob, function(error, result){
+ if (error) errback(new Error(error))();
+ else callback(result)();
+ });
+ };
+}
+
+exports.globAllFn = globAllFn;
, globAll
) where
+import Prelude (Unit(), ($))
+
import Control.Monad.Aff (Aff(), makeAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (Error())
foreign import data Glob :: !
-globAll :: forall eff. [String] -> Aff (glob :: Glob | eff) [[String]]
+globAll :: forall eff. Array String -> Aff (glob :: Glob | eff) (Array (Array String))
globAll patterns = makeAff $ runFn3 globAllFn patterns
-foreign import globAllFn """
-function globAllFn(patterns, errback, callback) {
- return function(){
- var glob = require('glob');
-
- var async = require('async');
-
- async.map(patterns, glob, function(error, result){
- if (error) errback(new Error(error))();
- else callback(result)();
- });
- };
-}
-""" :: forall eff. Fn3 [String]
- (Error -> Eff (glob :: Glob | eff) Unit)
- ([[String]] -> Eff (glob :: Glob | eff) Unit)
- (Eff (glob :: Glob | eff) Unit)
+foreign import globAllFn :: forall eff. Fn3 (Array String)
+ (Error -> Eff (glob :: Glob | eff) Unit)
+ ((Array (Array String)) -> Eff (glob :: Glob | eff) Unit)
+ (Eff (glob :: Glob | eff) Unit)
--- /dev/null
+'use strict'
+
+// module PursLoader.Loader
+
+var path = require('path');
+
+var cwd = process.cwd();
+
+function relative(from) {
+ return function(to){
+ return path.relative(from, to);
+ };
+}
+
+exports.cwd = cwd;
+
+exports.relative = relative;
, loaderFn
) where
+import Prelude (Unit(), ($), (<>), (>>=), (<$>), (++), bind, flip, id, pure, return, unit)
+
import Control.Monad.Aff (Aff(), runAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Class (liftEff)
(!!!) = flip (!!)
-foreign import cwd "var cwd = process.cwd();" :: String
+foreign import cwd :: String
-foreign import relative """
-function relative(from) {
- return function(to){
- var path = require('path');
- return path.relative(from, to);
- };
-}
-""" :: String -> String -> String
+foreign import relative :: String -> String -> String
-mkPsci :: [[String]] -> [[String]] -> String
+mkPsci :: Array (Array String) -> Array (Array String) -> String
mkPsci srcs ffis = joinWith "\n" ((loadModule <$> concat srcs) <> (loadForeign <$> concat ffis))
where
loadModule :: String -> String
loadForeign :: String -> String
loadForeign a = ":f " ++ relative cwd a
-findFFI :: forall eff. [[String]] -> String -> Aff (fs :: FS | eff) (Maybe String)
+findFFI :: forall eff. Array (Array String) -> String -> Aff (fs :: FS | eff) (Maybe String)
findFFI ffiss name = findFileUtf8 re (concat ffiss)
where
re = regex ("(?:^|\\n)//\\s*module\\s*" ++ name ++ "\\s*\\n") noFlags
writeFileUtf8 psciFilename psciFile
- let moduleName = match moduleRegex source >>= (!!!) 1
+ let moduleName = match moduleRegex source >>= (!!!) 1 >>= id
hasForeign = test foreignRegex source
result = (\a -> "module.exports = require('" ++ a ++ "');") <$> moduleName
--- /dev/null
+'use strict';
+
+// module PursLoader.LoaderRef
+
+function asyncFn(isJust, fromMaybe, ref){
+ return function(){
+ var callback = ref.async();
+ return function(error){
+ return function(value){
+ return function(){
+ return isJust(error) ? callback(fromMaybe(new Error())(error))
+ : callback(null, value);
+ };
+ };
+ };
+ };
+}
+function cacheable(ref){
+ return function(){
+ return ref.cacheable && ref.cacheable();
+ };
+}
+
+function query(ref){
+ return ref.query;
+}
+
+function clearDependencies(ref){
+ return function(){
+ return ref.clearDependencies();
+ };
+}
+
+function resourcePath(ref){
+ return ref.resourcePath;
+}
+
+function addDependency(ref){
+ return function(dep){
+ return function(){
+ return ref.addDependency(dep);
+ };
+ };
+}
+
+exports.asyncFn = asyncFn;
+
+exports.cacheable = cacheable;
+
+exports.query = query;
+
+exports.clearDependencies = clearDependencies;
+
+exports.resourcePath = resourcePath;
+
+exports.addDependency = addDependency;
, resourcePath
) where
+import Prelude (Unit())
+
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (Error())
foreign import data Loader :: !
-foreign import asyncFn """
-function asyncFn(isJust, fromMaybe, ref){
- return function(){
- var callback = ref.async();
- return function(error){
- return function(value){
- return function(){
- return isJust(error) ? callback(fromMaybe(new Error())(error))
- : callback(null, value);
- };
- };
- };
- };
-}""" :: forall eff a. Fn3 (Maybe Error -> Boolean)
- (Error -> Maybe Error -> Error)
- LoaderRef
- (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
+foreign import asyncFn :: forall eff a. Fn3 (Maybe Error -> Boolean)
+ (Error -> Maybe Error -> Error)
+ LoaderRef
+ (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
async ref = runFn3 asyncFn isJust fromMaybe ref
-foreign import cacheable """
-function cacheable(ref){
- return function(){
- return ref.cacheable && ref.cacheable();
- };
-}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
+foreign import cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
-foreign import query """
-function query(ref){
- return ref.query;
-}""" :: LoaderRef -> String
+foreign import query :: LoaderRef -> String
-foreign import clearDependencies """
-function clearDependencies(ref){
- return function(){
- return ref.clearDependencies();
- };
-}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
+foreign import clearDependencies :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
-foreign import resourcePath """
-function resourcePath(ref){
- return ref.resourcePath;
-}""" :: LoaderRef -> String
+foreign import resourcePath :: LoaderRef -> String
-foreign import addDependency """
-function addDependency(ref){
- return function(dep){
- return function(){
- return ref.addDependency(dep);
- };
- };
-}""" :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit
+foreign import addDependency :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit
--- /dev/null
+'use strict';
+
+// module PursLoader.LoaderUtil
+
+var loaderUtils = require('loader-utils');
+
+exports.parseQuery = loaderUtils.parseQuery;
import PursLoader.LoaderRef (LoaderRef())
-foreign import parseQuery """
-function parseQuery(query){
- var loaderUtils = require('loader-utils');
- return loaderUtils.parseQuery(query);
-}""" :: String -> Foreign
+foreign import parseQuery :: String -> Foreign
, loaderFFIOption
) where
+import Prelude (Unit(), (<>), (<$>), (<<<), (++), (<*>), const)
+
import Data.Array (concat)
import Data.Either (either)
, output :: NullOrUndefined String
, noPrefix :: NullOrUndefined Boolean
, requirePath :: NullOrUndefined String
- , src :: NullOrUndefined [String]
- , ffi :: NullOrUndefined [String]
+ , src :: NullOrUndefined (Array String)
+ , ffi :: NullOrUndefined (Array String)
}
instance isForeignOptions :: IsForeign Options where
<*> readProp ffiOpt obj)
class LoaderOption a where
- opt :: String -> NullOrUndefined a -> [String]
+ opt :: String -> NullOrUndefined a -> Array String
instance booleanLoaderOption :: LoaderOption Boolean where
opt key val = maybe [] (\a -> if a then ["--" ++ key] else []) (runNullOrUndefined val)
instance stringLoaderOption :: LoaderOption String where
opt key val = maybe [] (\a -> ["--" ++ key ++ "=" ++ a]) (runNullOrUndefined val)
-instance arrayLoaderOption :: (LoaderOption a) => LoaderOption [a] where
+instance arrayLoaderOption :: (LoaderOption a) => LoaderOption (Array a) where
opt key val = concat (opt key <$> (NullOrUndefined <<< Just)
<$> (fromMaybe [] (runNullOrUndefined val)))
-pscOptions :: Foreign -> [String]
+pscOptions :: Foreign -> Array String
pscOptions query = either (const []) fold parsed
where parsed = read query :: F Options
fold (Options a) = opt noPreludeOpt a.noPrelude <>
opt requirePathOpt a.requirePath <>
opt ffiOpt a.ffi
-loaderSrcOption :: Foreign -> Maybe [String]
+loaderSrcOption :: Foreign -> Maybe (Array String)
loaderSrcOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.src) (read query)
-loaderFFIOption :: Foreign -> Maybe [String]
+loaderFFIOption :: Foreign -> Maybe (Array String)
loaderFFIOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.ffi) (read query)