Skip to content
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

Merged
merged 8 commits into from
Oct 29, 2018
Merged

Documentation for Identity #330

merged 8 commits into from
Oct 29, 2018

Conversation

dalefrancis88
Copy link
Collaborator

@dalefrancis88 dalefrancis88 commented Oct 22, 2018

This is the initial commit for the Identity documentation for #42

This is the initial commit for the `Identity` documentation for #42
@coveralls
Copy link

coveralls commented Oct 23, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling ac78f8f on docs/Identity into 4ab96f5 on master.

Copy link
Owner

@evilsoft evilsoft left a 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`
Copy link
Owner

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
Copy link
Owner

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 Functors 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)

Copy link
Collaborator Author

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 :)

@@ -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] |
Copy link
Owner

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

Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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.
Copy link
Owner

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)

Copy link
Collaborator Author

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func -> function

@dalefrancis88 dalefrancis88 changed the title Initial scaffolding for Identity Documentation for Identity Oct 23, 2018
```

`of` is used to construct an `Identity` with any given value. It is there to
allow `Identity` to function as a pointed functor.
Copy link
Collaborator

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)
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space after target

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn man, nice 👀!

Copy link
Collaborator

@HenriqueLimas HenriqueLimas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice one 🎉 👍

@dalefrancis88 dalefrancis88 merged commit 6f16346 into master Oct 29, 2018
@dalefrancis88 dalefrancis88 deleted the docs/Identity branch October 29, 2018 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants