-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for Identity #330
Conversation
This is the initial commit for the `Identity` documentation for #42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback
<article id="topic-implements"> | ||
|
||
## Implements | ||
`Setoid`, `Semigroup`, `Functor`, `Chain`, `Traversable`, `Apply`, `Applicative`, `Monad` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list need to be in order of constraints imposed, so:
Setoid
, Semigroup
, Functor
, Apply
, Traversable
, Chain
, Applicative
, Monad
Identity a | ||
``` | ||
|
||
`Identity` is one of the most versatile `monads`. Although it does not have any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worried that this may be to much and going a little to deep on the Category Theory for the average learner.
Could the description be something like:
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.
Or something along those lines. Talk more about usage, then theory. Still give a little theory to put it in context with the other types, but focus more on its usage in the grand scheme of things. Without giving away too much.
(boy that is a wishy-washy suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha all good. Never thought the roles would be reversed and you'd tell me i was being too theoretical :)
docs/src/pages/docs/crocks/index.md
Outdated
@@ -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] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link refs should be all lowercase:
identity-valueOf -> identity-valueof
also missing the identity-valueof ref below.
|
||
of(true) | ||
//=> Identity true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline here, fences should hug the code tightly.
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Identity
-> an Identity
Identity (a -> b) ~> Identity a -> Identity b | ||
``` | ||
|
||
`ap` allows for values wrapped in a `Identity` to be applied to functions also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Identity
-> an Identity
``` | ||
|
||
`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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Identity
-> an Identity
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Identity
-> an Identity
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is provided -> to be provided
(may need to fix this in a couple places if this was copied)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came from Maybe
. After this commit i'll make that channge
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func -> function
``` | ||
|
||
`of` is used to construct an `Identity` with any given value. It is there to | ||
allow `Identity` to function as a pointed functor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to function
-> to work
|
||
const { of } = Identity | ||
|
||
of(42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Identity.of
instead, just for consistency since we use in that way in other docs.
|
||
`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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn man, nice 👀!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice one 🎉 👍
This is the initial commit for the
Identity
documentation for #42