
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
require-haskell
Advanced tools
require-haskell
lets you require
your haskell modules as asynchronous Javascript functions.
var requireH = require('require-haskell');
// You can now require haskell files with requireH just like you require javascript files using require.
var haskellFunction = requireH('/path/to/a/haskell/file.hs');
// Now you can call this function from your javascript code
haskellFunction('arguments', 'go', 'here', function(err, result){
// Now do something in the callback
});
The Javascript function representing the your Haskell module takes any number of arguments, and then a callback argument as it's last argument. Passing a callback is mandatory.
In the Haskell file, you can get the arguments passed in through the getArgs function from System.Environment. When your Haskell code is done executing, your callback that you passed gets called, with error
and result
arguments represening any errors thrown by the Haskell program or anything the program wrote to stderr in the error
argument, and anything the program wrote to standard output as the result
value.
If you want to call the Haskell module with certain environment variables set, you can pass a second argument when requiring your Haskell module. This argument should be an object containing any environment variables you want to set or overwrite.
var requireH = require('require-haskell');
var haskellFunctionWithEnvVariable = requireH('/some/file.hs', { VARNAME: 'foo' });
// Now when you call the function, the Haskell module will be run in a context that includes this new environment variable in addition to the ones it inherits from the Node proccess.
In order to use this module, you need to have runhaskell
installed on your system. If you've installed ghc
you've probably got it. Otherwise, you'll need to install it before you use require-haskell
.
require-haskell
dynamicly runs your Haskell code using runhaskell
. As such, it's not going to be as perfomant as if you compile the Haskell code up front and manually spawn a subproccess to run your compiled executable. require-haskell
is not intended for applications which need to do heavy lifting in Haskell, or ones which need to call the imported Haskell function many times per second.
What it is good for is scripting, EDSLs, or configuration files writted in Haskell. It's quite likely you'll be able to find even more uses for it.
To run the tests for require-haskell
, make sure you've installed jasmine
, and run npm test
.
Pull requests are welcome. If you've got an idea of how to improve require-haskell
go right ahead!
FAQs
Require haskell functions from node
The npm package require-haskell receives a total of 10 weekly downloads. As such, require-haskell popularity was classified as not popular.
We found that require-haskell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.