├── .gitignore ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joel Burget 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Webpack Haskell Loader 2 | 3 | Yep, you heard right. Use JavaScript and Haskell together as seen in this [video](http://youtu.be/DyFcrJL6kxk). 4 | 5 | ## Usage 6 | 7 | ```javascript 8 | var hsModule = require("haskell!./file.hs"); 9 | ``` 10 | 11 | Just as you'd expect, `hsModule` is an object holding all the symbols exported 12 | from the haskell module. 13 | 14 | As a prerequisite, you need the [Haste](http://haste-lang.org/) compiler 15 | installed. My 16 | [`commonjs`](https://github.com/joelburget/haste-compiler/tree/commonjs) 17 | branch, actually. 18 | 19 | ## Stability 20 | 21 | This is *very* early work and is quite unstable. It's an experiment, really. 22 | Please don't use it on anything you want to ship. 23 | 24 | ## License 25 | 26 | [MIT](http://www.opensource.org/licenses/mit-license.php) 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var spawnSync = require('spawn-sync'); 2 | 3 | module.exports = function(source) { 4 | this.cacheable && this.cacheable(); 5 | 6 | // get javascript from haste 7 | var result = spawnSync('haste-streaming', [], { 8 | input: source 9 | }); 10 | 11 | if (result.status !== 0) { 12 | this.emitError(result.stderr); 13 | } else { 14 | // If `onHotLoad` or `onHotUnload` is defined, swap in our definition. 15 | return result.stdout.toString().replace( 16 | /var (.*?) = require\(.*\)\['onHotLoad'\];/, 17 | "var $1 = function(f) { hotLoad = f; };" 18 | ).replace( 19 | /var (.*?) = require\(.*\)\['onHotUnload'\];/, 20 | "var $1 = function(f) { hotUnload = f; };" 21 | ); 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "haskell-loader", 3 | "version": "0.0.1", 4 | "author": "Joel Burget", 5 | "description": "Run Haskell files!", 6 | "dependencies": { 7 | "spawn-sync": "1.0.*", 8 | "event-stream": "^3.2.2" 9 | }, 10 | "licenses": [ 11 | { 12 | "type": "MIT", 13 | "url": "http://www.opensource.org/licenses/mit-license.php" 14 | } 15 | ] 16 | } 17 | --------------------------------------------------------------------------------