From 6ce00b53a5e25b1704597d4681c36cc537136b0c Mon Sep 17 00:00:00 2001 From: bsanches Date: Wed, 8 Jun 2016 09:54:15 -0700 Subject: [PATCH 1/2] Fix Comonad example - Current example doesn't run - `extract` is supposed to be a function - `this.v` is not a thing - Unfortunately, I'm not sure if it's possible to do this with arrow functions, as they'll bind the current `this` scope, which will be `CoIdentity`'s current scope instead of the actual returned object.. --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 034d745..affb88c 100644 --- a/readme.md +++ b/readme.md @@ -441,8 +441,8 @@ compose(foo, identity) ≍ compose(identity, foo) ≍ foo ```js let CoIdentity = v => ({ val: v, - extract: this.v, - extend: f => CoIdentity(f(this)) + extract: function () { return this.val }, + extend: function (f) { return CoIdentity(f(this)) } }) ``` From d857ea959842c083616e6a9c31b9e9592635e18a Mon Sep 17 00:00:00 2001 From: bsanches Date: Thu, 9 Jun 2016 20:40:18 -0700 Subject: [PATCH 2/2] use method shorthand for comonad example --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index affb88c..eca8af8 100644 --- a/readme.md +++ b/readme.md @@ -439,10 +439,10 @@ compose(foo, identity) ≍ compose(identity, foo) ≍ foo > An object that has `extract` and `extend` functions. ```js -let CoIdentity = v => ({ +const CoIdentity = v => ({ val: v, - extract: function () { return this.val }, - extend: function (f) { return CoIdentity(f(this)) } + extract() { return this.val }, + extend(f) { return CoIdentity(f(this)) } }) ```