From 11860a59203037b89917e7db7ade37022c2d465c Mon Sep 17 00:00:00 2001 From: David Chambers Date: Sat, 17 Dec 2016 00:07:25 +0100 Subject: [PATCH] update Extend and Comonad dependencies to match figure This commit also removes the third Comonad law. --- README.md | 7 ++++--- laws/comonad.js | 11 ++--------- test.js | 1 - 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 216e4cc..a07c71f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ structures: * [Bifunctor](#bifunctor) * [Profunctor](#profunctor) - + ## General @@ -457,6 +457,8 @@ the [Applicative](#applicative) and [Chain](#chain) specifications. ### Extend +A value that implements the Extend specification must also implement the [Functor](#functor) specification. + 1. `w.extend(g).extend(f)` is equivalent to `w.extend(_w => f(_w.extend(g)))` #### `extend` method @@ -481,11 +483,10 @@ method takes one argument: ### Comonad -A value that implements the Comonad specification must also implement the [Functor](#functor) and [Extend](#extend) specifications. +A value that implements the Comonad specification must also implement the [Extend](#extend) specification. 1. `w.extend(_w => _w.extract())` is equivalent to `w` 2. `w.extend(f).extract()` is equivalent to `f(w)` -3. `w.extend(f)` is equivalent to `w.extend(x => x).map(f)` #### `extract` method diff --git a/laws/comonad.js b/laws/comonad.js index df6ae08..f56ece1 100644 --- a/laws/comonad.js +++ b/laws/comonad.js @@ -1,7 +1,7 @@ 'use strict'; const {identity} = require('fantasy-combinators'); -const {extend, map, extract} = require('..'); +const {extend, extract} = require('..'); /** @@ -9,7 +9,6 @@ const {extend, map, extract} = require('..'); 1. `w.extend(_w => _w.extract())` is equivalent to `w` 2. `w.extend(f).extract()` is equivalent to `f(w)` -3. `w.extend(f)` is equivalent to `w.extend(x => x).map(f)` **/ @@ -25,10 +24,4 @@ const rightIdentity = t => eq => x => { return eq(a, b); }; -const associativity = t => eq => x => { - const a = t(x)[extend](identity); - const b = t(x)[extend](identity)[map](identity); - return eq(a, b); -}; - -module.exports = {leftIdentity, rightIdentity, associativity}; +module.exports = {leftIdentity, rightIdentity}; diff --git a/test.js b/test.js index f0565c4..0d401a3 100644 --- a/test.js +++ b/test.js @@ -67,7 +67,6 @@ exports.chainRec = { exports.comonad = { leftIdentity: test(comonad.leftIdentity(Id[fl.of])(equality)), rightIdentity: test(comonad.rightIdentity(Id[fl.of])(equality)), - associativity: test(comonad.associativity(Id[fl.of])(equality)), }; exports.extend = {