Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akh.codensity

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akh.codensity - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

tests/codensityT.js

3

CHANGELOG.md
# ChangeLog
## 0.0.2 - September 2, 2016
* Small cleanups for merge with akh.
## 0.0.0 - August 31, 2016
* Initial release.

13

index.js
"use strict"
const CodensityT = require('./trans/codensity');
const Codensity = require('./type/codensity');
const codensityT = require('./trans/codensity');
const codensity = require('./type/codensity');
module.exports = {
CodensityT: codensityT,
Codensity: codensity,
CodensityT: CodensityT,
Codensity: Codensity,
trans: { codensity: codensityT },
type: { codensity: codensity }
trans: { codensity: CodensityT },
type: { codensity: Codensity }
};
{
"name": "akh.codensity",
"version": "0.0.1",
"description": "Akh codensity monad",
"author": "Matt Bierner",
"license": "MIT",
"keywords": [
"monad transformer",
"monad",
"akh",
"codensity"
],
"repository": {
"type": "git",
"url": "https://github.com/mattbierner/akh-codensity.git"
},
"bugs": {
"url": "https://github.com/mattbierner/akh-codensity/issues"
},
"main": "index.js",
"dependencies": {
"akh.core.spec": "0.x",
"akh.core.trampoline": "^0.0.0",
"akh.identity": "^0.1.0"
},
"devDependencies": {
"chai": "*",
"mocha": "*"
},
"scripts": {
"test": "mocha ./tests"
}
}
"name": "akh.codensity",
"version": "0.0.2",
"description": "Akh codensity monad",
"author": "Matt Bierner",
"license": "MIT",
"keywords": [
"monad transformer",
"monad",
"akh",
"codensity"
],
"repository": {
"type": "git",
"url": "https://github.com/mattbierner/akh-codensity.git"
},
"bugs": {
"url": "https://github.com/mattbierner/akh-codensity/issues"
},
"main": "index.js",
"dependencies": {
"akh.core.spec": "0.x",
"akh.core.trampoline": "^0.0.0",
"akh.identity": "^0.1.0"
},
"devDependencies": {
"akh.state": "^0.0.0",
"chai": "*",
"mocha": "*"
},
"scripts": {
"test": "mocha ./tests"
}
}

@@ -1,30 +0,60 @@

[Akh](https://github.com/mattbierner/akh) continuation monad
# Codensity for the [Akh Javascript Monad Transformer Library](https://github.com/mattbierner/akh)
## API
Includes both regular [codensity][] monad `Codensity` and codensity monad transformer `CodensityT`.
### `require('akh.cont').Cont`
Codensity.
```bash
# To use as standalone package
$ npm install --save akh.codensity
#### `Cont.run(m, k)`
Perform a continuation computation `m` and complete with outer continuation `k`.
# To use as part of akh library
$ npm install --save akh
```
## Usage
The codensity monad/transformer implements the [Fantasy Land][fl] monad and monoid interfaces.
<a href="https://github.com/fantasyland/fantasy-land">
<img src="https://raw.github.com/fantasyland/fantasy-land/master/logo.png" align="right" width="82px" height="82px" alt="Fantasy Land logo" />
</a>
```js
const cont = requre('akh.Codensity').Codensity
// Continuation monad
require('akh.codensity').Codensity
require('akh').Codensity
var c = cont.of(3)
.callcc(k =>
k(4).map(x => x + 1))
.map((x) => -x);
// Continuation monad transformer
require('akh.codensity').CodensityT
require('akh').CodensityT
```
cont.run(c, console.log); // logs: -4
#### `Codensity.run(m, k)`, `m.run(k)`
Perform a codensity computation `m` and complete with outer continuation `k`.
```js
const Codensity = requre('akh.Codensity').Codensity
var c = Codensity.of(3).map(x => -x)
Codensity.run(c, console.log) // logs: -3
c.run(console.log)
```
----
#### `CodensityT.run(m, k)`, `m.run(k)`
Same as `Codensity.run` but for transformed types
### `require('akh.codensity').CodensityT`
The codensity transformer, layers codensity over a monad. 
#### `CodensityT.run(m, k)`
Same as `Codensity.run` but for transformed types
## Contributing
Contributions are welcome.
To get started:
```bash
$ cd akh-codensity
$ npm install # install dev packages
$ npm test # run tests
```
[codensity]: http://www.maths.ed.ac.uk/~tl/sydney/sydney_talk.pdf
[fl]: https://github.com/fantasyland/fantasy-land

@@ -5,3 +5,3 @@ "use strict";

const sqr = function (x) { return x * x }
const sqr = x => x * x

@@ -12,5 +12,4 @@ describe("Codensity", () => {

assert.deepEqual(
Codensity.run(c, sqr),
9)
assert.deepEqual(9, Codensity.run(c, sqr))
assert.deepEqual(9, c.run(sqr))
})

@@ -17,0 +16,0 @@

@@ -8,4 +8,3 @@ /**

/* Transformer
******************************************************************************/
var runCodensityT = (m, k) =>

@@ -46,3 +45,2 @@ tramp.tail(m._run, k)

Instance.prototype.run = function(k) {

@@ -58,3 +56,3 @@ return CodensityT.run(this, k);

*
* @param m ContT computation.
* @param m Codensity computation.
* @param k Outer continuation.

@@ -65,3 +63,3 @@ */

module.exports = CodensityT

@@ -6,3 +6,3 @@ "use strict"

/**
* Codensity monad
* Codensity monad.
*/

@@ -9,0 +9,0 @@ const Codensity = CodensityT(Identity);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc