From 566c922bfa8da743218cefed0c0f7907b535769f Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Sun, 21 Oct 2018 22:58:34 -0700 Subject: [PATCH 1/7] Initial scaffolding for Identity This is the initial commit for the `Identity` documentation for #42 --- docs/src/pages/docs/crocks/Identity.md | 226 +++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 docs/src/pages/docs/crocks/Identity.md diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md new file mode 100644 index 000000000..650262b90 --- /dev/null +++ b/docs/src/pages/docs/crocks/Identity.md @@ -0,0 +1,226 @@ +--- +title: "Identity" +description: "Identity Crock" +layout: "guide" +weight: 60 +--- + +```haskell +Identity a +``` + +`Identity` is one of the most versatile `monads`. It does not have any inherant +behaviour and simply applies the given `function` to it's value. `Identity` is +often used in place where a `monad` or `applicative` is expected. +Identity is also known the "empty" functor and applicative functor. `Identity` +composed with another functor or applicative functor is isomorphic to the +original. + +```javascript +import Identity from 'crocks/Identity' + +Identity(10) +//=> Identity 10 +``` +
+ +## Implements +`Setoid`, `Semigroup`, `Functor`, `Chain`, `Traversable`, `Apply`, `Applicative`, `Monad` + +
+ +
+ +## Construction + +```haskell +Identity :: a -> Identity a +``` + + +```javascript +import Identity from 'crocks/Identity' + +Identity(42) +//=> Identity 42 + +``` + +
+ +
+ +## Constructor Methods + +#### of + +```haskell +Identity.of :: a -> Identity a +``` + +`of` is used to construct an `Identity` with ... + +```javascript +import Identity from 'crocks/Identity' + +Identity.of(42) +//=> Identity 42 + +``` + +
+ +
+ +## Instance Methods + +#### equals + +```haskell +Identity a ~> b -> Boolean +``` + +Used to compare the underlying values of two `Identity` instances for equality by +value, `equals` takes any given argument and returns `true` if the passed +arguments is a `Identity` with an underlying value equal to the underlying value +of the `Identity` the method is being called on. If the passed argument is not +an `Identity` or the underlying values are not equal, `equals` will return `false`. + +```javascript +import Identity from 'crocks/Identity' + +import equals from 'crocks/pointfree/equals' + +Identity(33) + .equals(Identity(33)) +//=> true + +Identity(33) + .equals(Identity('33')) +//=> false + +// by value, not reference for most types +Identity({ a: 86, b: true }) + .equals(Identity({ a: 86, b: true })) +//=> true + +equals(Identity(95), 95) +//=> false + +equals(Identity([ 2, 3 ]), Identity([ 2, 3 ])) +//=> true +``` + +#### concat + +```haskell +Identity s => Identity s ~> Identity s -> Identity s +``` + +When an underlying value of a given `Identity` is fixed to a `Semigroup`, +`concat` can be used to concat another `Identity` instance with an underlying +`Semigroup` of the same type. Expecting a `Identity` wrapping a `Semigroup` of +the same type, `concat` will give back a new `Identity` instance wrapping the +result of combining the two underlying `Semigroup`s. + +```javascript +import Identity from 'crocks/Identity' + +import Sum from 'crocks/Sum' + +import compose from 'crocks/helpers/compose' +import concat from 'crocks/pointfree/concat' +import flip from 'crocks/combinators/flip' +import map from 'crocks/pointfree/map' +import mapReduce from 'crocks/helpers/mapReduce' +import valueOf from 'crocks/pointfree/valueOf' + +// empty :: Identity Sum +const empty = + Identity(Sum.empty()) + +// sumList :: [ * ] -> Identity Number +const sumList = compose( + map(valueOf), + mapReduce(compose(Identity, Sum), flip(concat), empty) +) + +Identity([ 34 ]) + .concat(Identity([ 92 ])) +//=> Identity [ 34, 92 ] + +sumList([ 3, 4, 5 ]) +//=> Identity 12 + +``` + +#### map + +```haskell +Identity a ~> (a -> b) -> Identity b +``` + + +```javascript +import Identity from 'crocks/Identity' + +const prod = a => b => a * b +const double = prod(2) + +Identity(5) + .map(double) +//=> Identity 10 +``` + +#### ap + +```haskell +Identity (a -> b) ~> Identity a -> Identity b +``` + +`ap` allows for values wrapped in a `Identity` to be applied to functions also +wrapped in a `Identity`. In order to use `ap`, the `Identity` must contain a +function as its value. Under the hood, `ap` unwraps both the function +and the value to be applied and applies the value to the function. Finally it +will wrap the result of that application back into a `Identity`. It is required +that the inner function is curried. + +```javascript +import Identity from 'crocks/Identity' + +const prod = a => b => a * b +const double = prod(2) + +Identity(double) + .ap(5) +//=> Identity 10 + +``` + +#### sequence + +#### traverse + +#### chain + +```haskell +Identity a ~> (a -> Identity b) -> Identity b +``` + +Normally one of the ways `Monad`s like `Identity`... + +```javascript +import Identity from 'crocks/Identity' +import compose from 'crocks/helpers/compose' + +const prod = a => b => a * b +const doubleAsIdentity = compose(Identity, prod(2)) + +Identity(5) + .chain(doubleAsIdentity) +//=> Identity 10 + +``` + + +
From 597e3b80f49b33653797f851c028dc1a982fcae7 Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Tue, 23 Oct 2018 00:24:00 -0700 Subject: [PATCH 2/7] Added Chain updated map and constructor docs --- docs/src/pages/docs/crocks/Identity.md | 33 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index 650262b90..7229d7716 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -37,12 +37,17 @@ Identity(10) Identity :: a -> Identity a ``` +The contstructor for an `Identity` is a unary function. When a value is passed +in an `Identity` of the given value is returned ready for `map` or `chain`. ```javascript import Identity from 'crocks/Identity' +const fromComputerCode = String.fromCharCode + Identity(42) -//=> Identity 42 + .map(fromComputerCode) +//=> Identity '*' ``` @@ -58,7 +63,7 @@ Identity(42) Identity.of :: a -> Identity a ``` -`of` is used to construct an `Identity` with ... +`of` is used to construct an `Identity` with any given value. ```javascript import Identity from 'crocks/Identity' @@ -160,15 +165,20 @@ sumList([ 3, 4, 5 ]) Identity a ~> (a -> b) -> Identity b ``` +Used to apply transformations to values you've lifted into an `Identity`, `map` +takes a function that it will lift into the context of the `Identity` and apply +to it the wrapped value. `Identity` contains no bahaviour and will do nothing +more than apply the value inside the `Identity` to the function. ```javascript import Identity from 'crocks/Identity' +import map from 'crocks/pointfree/map' const prod = a => b => a * b -const double = prod(2) -Identity(5) - .map(double) +const mapDouble = map(prod(2)) + +mapDouble(Identity(5)) //=> Identity 10 ``` @@ -207,20 +217,25 @@ Identity(double) Identity a ~> (a -> Identity b) -> Identity b ``` -Normally one of the ways `Monad`s like `Identity`... +Normally one of the ways `Monad`s like `Identity` are able to be combined and +have their effects applied is through `chain`. However `Identity` is different +because there are no effects to apply. `chain` will simply take a func that +returns `Identity` and applies it to its value. ```javascript import Identity from 'crocks/Identity' import compose from 'crocks/helpers/compose' +import chain from 'crocks/pointfree/chain' const prod = a => b => a * b const doubleAsIdentity = compose(Identity, prod(2)) -Identity(5) - .chain(doubleAsIdentity) +doubleAsIdentity(21) +//=> Identity 42 + +chain(doubleAsIdentity, Identity(5)) //=> Identity 10 ``` - From 588ce687430eacd83723d86a8cb414106006022a Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Tue, 23 Oct 2018 10:49:54 -0700 Subject: [PATCH 3/7] Adding to index, updated sequence --- docs/src/pages/docs/crocks/Identity.md | 43 +++++++++++++++++++++++--- docs/src/pages/docs/crocks/index.md | 13 +++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index 7229d7716..107d0a296 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -9,9 +9,10 @@ weight: 60 Identity a ``` -`Identity` is one of the most versatile `monads`. It does not have any inherant -behaviour and simply applies the given `function` to it's value. `Identity` is -often used in place where a `monad` or `applicative` is expected. +`Identity` is one of the most versatile `monads`. Although it does not have any +inherant behaviour its power comes from lifting a simple value into the monadic +space and applying the given `function` (`map`/`chain`/etc) to it's value. +`Identity` is often used in place where a `monad` or `applicative` is expected. Identity is also known the "empty" functor and applicative functor. `Identity` composed with another functor or applicative functor is isomorphic to the original. @@ -63,14 +64,20 @@ Identity(42) Identity.of :: a -> Identity a ``` -`of` is used to construct an `Identity` with any given value. +`of` is used to construct an `Identity` with any given value. It is there to +allow `Identity` to function as a pointed functor. ```javascript import Identity from 'crocks/Identity' -Identity.of(42) +const { of } = Identity + +of(42) //=> Identity 42 +of(true) +//=> Identity true + ``` @@ -209,6 +216,32 @@ Identity(double) #### sequence +```haskell +Apply f => Identity (f a) ~> (b -> f b) -> f (Identity a) +Applicative f => Identity (f a) ~> TypeRep f -> f (Identity a) +``` + +When an instance of `Identity` wraps an `Apply` instance, `sequence` can be used to +swap the type sequence. `sequence` requires either an `Applicative TypeRep` or +an `Apply` returning function is provided for its argument. + +`sequence` can be derived from [`traverse`](#traverse) by passing it an +`identity` function (`x => x`). + +```javascript +import Identity from 'crocks/Identity' + +import Maybe from 'crocks/Maybe' +import sequence from 'crocks/pointfree/sequence' + +// seqId :: Identity Maybe a -> Maybe Identity a +const seqMaybe = + sequence(Maybe) + +seqMaybe(Identity(Maybe(42))) +//=> Just Identity 42 +``` + #### traverse #### chain diff --git a/docs/src/pages/docs/crocks/index.md b/docs/src/pages/docs/crocks/index.md index 2034641ba..18b8051fd 100644 --- a/docs/src/pages/docs/crocks/index.md +++ b/docs/src/pages/docs/crocks/index.md @@ -22,7 +22,7 @@ names, but what they do from type to type may vary. | [`Const`][const] | -- | [`ap`][const-ap], [`chain`][const-chain], [`concat`][const-concat], [`equals`][const-equals], [`map`][const-map], [`valueOf`][const-valueof] | | [`Either`][either] | [`Left`][either-left], [`Right`][either-right], [`of`][either-of]| [`alt`][either-alt], [`ap`][either-ap], [`bimap`][either-bimap], [`chain`][either-chain], [`coalesce`][either-coalesce], [`concat`][either-concat], [`either`][either-either], [`equals`][either-equals], [`map`][either-map], [`of`][either-of], [`sequence`][either-sequence], [`swap`][either-swap], [`traverse`][either-traverse] | | [`Equiv`][equiv] | [`empty`][equiv-empty] | [`concat`][equiv-concat], [`contramap`][equiv-contra], [`compareWith`][equiv-compare], [`valueOf`][equiv-value] | -| `Identity` | `of` | `ap`, `chain`, `concat`, `equals`, `map`, `of`, `sequence`, `traverse`, `valueOf` | +| [`Identity`][identity] | [`of`][identity-of] | [`ap`][identity-ap], [`chain`][identity-chain], [`concat`][identity-concat], [`equals`][identity-equals], [`map`][identity-map], [`of`][identity-of], [`sequence`][identity-sequence], [`traverse`][identity-traverse], [`valueOf`][identity-valueOf] | | `IO` | `of` | `ap`, `chain`, `map`, `of`, `run` | | `List` | `empty`, `fromArray`, `of` | `ap`, `chain`, `concat`, `cons`, `empty`, `equals`, `filter`, `fold`, `foldMap`, `head`, `map`, `of`, `reduce`, `reduceRight`, `reject`, `sequence`, `tail`, `toArray`, `traverse`, `valueOf` | | [`Maybe`][maybe] | [`Nothing`][maybe-nothing], [`Just`][maybe-just], [`of`][maybe-of], [`zero`][maybe-zero] | [`alt`][maybe-alt], [`ap`][maybe-ap], [`chain`][maybe-chain], [`coalesce`][maybe-coalesce], [`concat`][maybe-concat], [`equals`][maybe-equals], [`either`][maybe-either], [`map`][maybe-map], [`of`][maybe-of], [`option`][maybe-option], [`sequence`][maybe-sequence], [`traverse`][maybe-traverse], [`zero`][maybe-zero] | @@ -95,6 +95,17 @@ names, but what they do from type to type may vary. [either-swap]: Either.html#swap [either-traverse]: Either.html#traverse +[identity]: Identity.html +[identity-of]: Identity.html#of +[identity-alt]: Identity.html#alt +[identity-ap]: Identity.html#ap +[identity-chain]: Identity.html#chain +[identity-concat]: Identity.html#concat +[identity-equals]: Identity.html#equals +[identity-map]: Identity.html#map +[identity-sequence]: Identity.html#sequence +[identity-traverse]: Identity.html#traverse + [equiv]: Equiv.html [equiv-empty]: Equiv.html#empty [equiv-concat]: Equiv.html#concat From c19b3c0cc663f7c73e97496f7757a7dfb5dd3e48 Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Tue, 23 Oct 2018 13:49:45 -0700 Subject: [PATCH 4/7] Changes per review plus added sequence docs --- docs/src/pages/docs/crocks/Identity.md | 107 ++++++++++++++++++++----- docs/src/pages/docs/crocks/Maybe.md | 1 - docs/src/pages/docs/crocks/Pair.md | 2 +- docs/src/pages/docs/crocks/index.md | 3 +- 4 files changed, 92 insertions(+), 21 deletions(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index 107d0a296..1628eb0f1 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -9,13 +9,12 @@ weight: 60 Identity a ``` -`Identity` is one of the most versatile `monads`. Although it does not have any -inherant behaviour its power comes from lifting a simple value into the monadic -space and applying the given `function` (`map`/`chain`/etc) to it's value. -`Identity` is often used in place where a `monad` or `applicative` is expected. -Identity is also known the "empty" functor and applicative functor. `Identity` -composed with another functor or applicative functor is isomorphic to the -original. +`Identity` is a `crock` that can be used to wrap a common interface around +existing Javascript types and functions. It maintains integrity by lifting +and applying functions and types as is, without adding any additional structure +or effects. By not applying and additional structure to existing functions, +`Identity` can be swapped in and out for other `Functor`s that do apply their +own structure and effects. ```javascript import Identity from 'crocks/Identity' @@ -26,7 +25,7 @@ Identity(10)
## Implements -`Setoid`, `Semigroup`, `Functor`, `Chain`, `Traversable`, `Apply`, `Applicative`, `Monad` +`Setoid`, `Semigroup`, `Functor`, `Traversable`, `Apply`, `Chain`, `Applicative`, `Monad`
@@ -79,7 +78,6 @@ of(true) //=> Identity true ``` -
@@ -94,7 +92,7 @@ Identity a ~> b -> Boolean Used to compare the underlying values of two `Identity` instances for equality by value, `equals` takes any given argument and returns `true` if the passed -arguments is a `Identity` with an underlying value equal to the underlying value +arguments is an `Identity` with an underlying value equal to the underlying value of the `Identity` the method is being called on. If the passed argument is not an `Identity` or the underlying values are not equal, `equals` will return `false`. @@ -131,7 +129,7 @@ Identity s => Identity s ~> Identity s -> Identity s When an underlying value of a given `Identity` is fixed to a `Semigroup`, `concat` can be used to concat another `Identity` instance with an underlying -`Semigroup` of the same type. Expecting a `Identity` wrapping a `Semigroup` of +`Semigroup` of the same type. Expecting an `Identity` wrapping a `Semigroup` of the same type, `concat` will give back a new `Identity` instance wrapping the result of combining the two underlying `Semigroup`s. @@ -163,7 +161,6 @@ Identity([ 34 ]) sumList([ 3, 4, 5 ]) //=> Identity 12 - ``` #### map @@ -195,11 +192,11 @@ mapDouble(Identity(5)) Identity (a -> b) ~> Identity a -> Identity b ``` -`ap` allows for values wrapped in a `Identity` to be applied to functions also -wrapped in a `Identity`. In order to use `ap`, the `Identity` must contain a +`ap` allows for values wrapped in an `Identity` to be applied to functions also +wrapped in an `Identity`. In order to use `ap`, the `Identity` must contain a function as its value. Under the hood, `ap` unwraps both the function and the value to be applied and applies the value to the function. Finally it -will wrap the result of that application back into a `Identity`. It is required +will wrap the result of that application back into an `Identity`. It is required that the inner function is curried. ```javascript @@ -211,7 +208,6 @@ const double = prod(2) Identity(double) .ap(5) //=> Identity 10 - ``` #### sequence @@ -223,7 +219,7 @@ Applicative f => Identity (f a) ~> TypeRep f -> f (Identity a) When an instance of `Identity` wraps an `Apply` instance, `sequence` can be used to swap the type sequence. `sequence` requires either an `Applicative TypeRep` or -an `Apply` returning function is provided for its argument. +an `Apply` returning function to be provided for its argument. `sequence` can be derived from [`traverse`](#traverse) by passing it an `identity` function (`x => x`). @@ -244,6 +240,59 @@ seqMaybe(Identity(Maybe(42))) #### traverse +```haskell +Apply f => Identity a ~> (a -> f b) -> f (Identity b) +Applicative f => Identity a ~> (TypeRep f, (a -> f b)) -> f (Identity a b) +``` + +Used to apply the "effect" of an `Apply` to a value inside of a `Identity`, +`traverse` combines both the "effects" of the `Apply` and the `Identity` by +returning a new instance of the `Apply`, wrapping the result of the +`Apply`s "effect" on the value in the `Identity`. + +`traverse` requires either an `Applicative TypeRep` or an `Apply` returning +function as its first argument and a function that is used to apply the "effect" +of the target `Apply` to the value inside of the `Identity`. Both arguments must provide +an instance of the target `Apply`. + +```javascript +import Identity from 'crocks/Identity' +import IO from 'crocks/IO' + +import compose from 'crocks/helpers/compose' +import isNumber from 'crocks/predicates/isNumber' +import traverse from 'crocks/pointfree/traverse' +import ifElse from 'crocks/logic/ifElse' + +// someGlobal :: Number +let someGlobal = 10 + +// addToGlobal :: Number -> IO Number +const addToGlobal = x => IO(() => someGlobal + x) + +// safeAddToGlobal :: a -> IO (Maybe Number) +const safeAddToGlobal = compose( + traverse(IO, addToGlobal), + Identity, + ifElse(isNumber, x => x, () => NaN) +) + +safeAddToGlobal(32) + .run() +//=> Identity 42 +//someGlobal => 42 + +safeAddToGlobal(32) + .run() + .valueOf() +//=> 42 + +safeAddToGlobal(undefined) + .run() + .valueOf() +//=> NaN +``` + #### chain ```haskell @@ -252,7 +301,7 @@ Identity a ~> (a -> Identity b) -> Identity b Normally one of the ways `Monad`s like `Identity` are able to be combined and have their effects applied is through `chain`. However `Identity` is different -because there are no effects to apply. `chain` will simply take a func that +because there are no effects to apply. `chain` will simply take a function that returns `Identity` and applies it to its value. ```javascript @@ -268,7 +317,29 @@ doubleAsIdentity(21) chain(doubleAsIdentity, Identity(5)) //=> Identity 10 +``` + +#### valueOf + +```haskell +Identity a ~> () -> a +``` + +`valueOf` is used as a means of extraction. This function is used primarily for +convenience for some of the helper functions that ship with `crocks`. Calling +`valueOf` on an `Identity` instance will return the value being contained. + +```javascript +import Identity from 'crocks/Identity' + +Identity(42) + .valueOf() +//=> 33 +Identity(20) + .concat(Identity(22)) + .valueOf() +//=> 35 ```
diff --git a/docs/src/pages/docs/crocks/Maybe.md b/docs/src/pages/docs/crocks/Maybe.md index 0c188783b..e5b04b3a1 100644 --- a/docs/src/pages/docs/crocks/Maybe.md +++ b/docs/src/pages/docs/crocks/Maybe.md @@ -730,7 +730,6 @@ safeAddToGlobal(32) safeAddToGlobal(undefined) .run() //=> Nothing -//someGlobal => 42 ``` #### chain diff --git a/docs/src/pages/docs/crocks/Pair.md b/docs/src/pages/docs/crocks/Pair.md index 0b0377fc9..e10754936 100644 --- a/docs/src/pages/docs/crocks/Pair.md +++ b/docs/src/pages/docs/crocks/Pair.md @@ -480,7 +480,7 @@ flow(pair) #### traverse ```haskell -Apply f => Pair a b ~> (d -> f d), (b -> f c)) -> f (Pair a c) +Apply f => Pair a b ~> ((d -> f d), (b -> f c)) -> f (Pair a c) Applicative f => Pair a b ~> (TypeRep f, (b -> f c)) -> f (Pair a c) ``` diff --git a/docs/src/pages/docs/crocks/index.md b/docs/src/pages/docs/crocks/index.md index 18b8051fd..f27138a8a 100644 --- a/docs/src/pages/docs/crocks/index.md +++ b/docs/src/pages/docs/crocks/index.md @@ -22,7 +22,7 @@ names, but what they do from type to type may vary. | [`Const`][const] | -- | [`ap`][const-ap], [`chain`][const-chain], [`concat`][const-concat], [`equals`][const-equals], [`map`][const-map], [`valueOf`][const-valueof] | | [`Either`][either] | [`Left`][either-left], [`Right`][either-right], [`of`][either-of]| [`alt`][either-alt], [`ap`][either-ap], [`bimap`][either-bimap], [`chain`][either-chain], [`coalesce`][either-coalesce], [`concat`][either-concat], [`either`][either-either], [`equals`][either-equals], [`map`][either-map], [`of`][either-of], [`sequence`][either-sequence], [`swap`][either-swap], [`traverse`][either-traverse] | | [`Equiv`][equiv] | [`empty`][equiv-empty] | [`concat`][equiv-concat], [`contramap`][equiv-contra], [`compareWith`][equiv-compare], [`valueOf`][equiv-value] | -| [`Identity`][identity] | [`of`][identity-of] | [`ap`][identity-ap], [`chain`][identity-chain], [`concat`][identity-concat], [`equals`][identity-equals], [`map`][identity-map], [`of`][identity-of], [`sequence`][identity-sequence], [`traverse`][identity-traverse], [`valueOf`][identity-valueOf] | +| [`Identity`][identity] | [`of`][identity-of] | [`ap`][identity-ap], [`chain`][identity-chain], [`concat`][identity-concat], [`equals`][identity-equals], [`map`][identity-map], [`of`][identity-of], [`sequence`][identity-sequence], [`traverse`][identity-traverse], [`valueOf`][identity-valueof] | | `IO` | `of` | `ap`, `chain`, `map`, `of`, `run` | | `List` | `empty`, `fromArray`, `of` | `ap`, `chain`, `concat`, `cons`, `empty`, `equals`, `filter`, `fold`, `foldMap`, `head`, `map`, `of`, `reduce`, `reduceRight`, `reject`, `sequence`, `tail`, `toArray`, `traverse`, `valueOf` | | [`Maybe`][maybe] | [`Nothing`][maybe-nothing], [`Just`][maybe-just], [`of`][maybe-of], [`zero`][maybe-zero] | [`alt`][maybe-alt], [`ap`][maybe-ap], [`chain`][maybe-chain], [`coalesce`][maybe-coalesce], [`concat`][maybe-concat], [`equals`][maybe-equals], [`either`][maybe-either], [`map`][maybe-map], [`of`][maybe-of], [`option`][maybe-option], [`sequence`][maybe-sequence], [`traverse`][maybe-traverse], [`zero`][maybe-zero] | @@ -105,6 +105,7 @@ names, but what they do from type to type may vary. [identity-map]: Identity.html#map [identity-sequence]: Identity.html#sequence [identity-traverse]: Identity.html#traverse +[identity-valueof]: Identity.html#valueof [equiv]: Equiv.html [equiv-empty]: Equiv.html#empty From 246c0053bbd20b29c20fa14807769c7018144cbf Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Tue, 23 Oct 2018 13:52:12 -0700 Subject: [PATCH 5/7] Missed an extra line --- docs/src/pages/docs/crocks/Identity.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index 1628eb0f1..1293e11a9 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -48,7 +48,6 @@ const fromComputerCode = String.fromCharCode Identity(42) .map(fromComputerCode) //=> Identity '*' - ``` @@ -76,8 +75,8 @@ of(42) of(true) //=> Identity true - ``` +
From d7050625479fea986d4ac0715ebf8aef6d9f42e0 Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Tue, 23 Oct 2018 22:06:20 -0700 Subject: [PATCH 6/7] bahaviour -> behavior --- docs/src/pages/docs/crocks/Identity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index 1293e11a9..e3fbebe6a 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -170,7 +170,7 @@ Identity a ~> (a -> b) -> Identity b Used to apply transformations to values you've lifted into an `Identity`, `map` takes a function that it will lift into the context of the `Identity` and apply -to it the wrapped value. `Identity` contains no bahaviour and will do nothing +to it the wrapped value. `Identity` contains no behavior and will do nothing more than apply the value inside the `Identity` to the function. ```javascript From ac78f8f58c4b20497ecd1dc4bd5cf8e647cfa8c5 Mon Sep 17 00:00:00 2001 From: Dale Francis Date: Sun, 28 Oct 2018 22:45:47 -0700 Subject: [PATCH 7/7] Updates per review --- docs/src/pages/docs/crocks/Identity.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/src/pages/docs/crocks/Identity.md b/docs/src/pages/docs/crocks/Identity.md index e3fbebe6a..50987bdcf 100644 --- a/docs/src/pages/docs/crocks/Identity.md +++ b/docs/src/pages/docs/crocks/Identity.md @@ -63,17 +63,15 @@ Identity.of :: a -> Identity a ``` `of` is used to construct an `Identity` with any given value. It is there to -allow `Identity` to function as a pointed functor. +allow `Identity` to work as a pointed functor. ```javascript import Identity from 'crocks/Identity' -const { of } = Identity - -of(42) +Identity.of(42) //=> Identity 42 -of(true) +Identity.of(true) //=> Identity true ``` @@ -251,7 +249,7 @@ returning a new instance of the `Apply`, wrapping the result of the `traverse` requires either an `Applicative TypeRep` or an `Apply` returning function as its first argument and a function that is used to apply the "effect" -of the target `Apply` to the value inside of the `Identity`. Both arguments must provide +of the target `Apply` to the value inside of the `Identity`. Both arguments must provide an instance of the target `Apply`. ```javascript