-
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
Adds Identity API to docs #38
Changes from 1 commit
95d13a7
facce30
077e492
fa420c7
b2775be
82df8f7
3020043
3736fbb
32be547
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,11 @@ | |
|
||
`Identity : a -> a` | ||
|
||
It's just a function which returns what you pass into it. | ||
Crock which returns the same value that was used as its argument | ||
|
||
## What a crock! | ||
## Why? | ||
|
||
It converts your `non-crock` into a `crock` | ||
|
||
```js | ||
const frozenPizza = Identity('pizza') //Identity pizza | ||
const microwave = x => 'microwave ' + x | ||
const dinner = frozenPizza.map(microwave) //Identity "microwave pizza" | ||
dinner.value() // "microwave pizza" | ||
``` | ||
To expose the constructor and instances defined below | ||
|
||
| Constructor | Instance | | ||
|:---|:---| | ||
|
@@ -23,41 +16,38 @@ dinner.value() // "microwave pizza" | |
|
||
### of | ||
|
||
```js | ||
crocks.Identity.of([1,2,10]) | ||
crocks.Identity([1,2,10]) | ||
``` | ||
`Identity a => a -> Identity a` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be something like: |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Different type of definition for constructor; here is only a definition by example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So the constructor parameters should be represented by the type siggy in most cases. Also for Maybe, it also takes an internal UnionType and if it is not the UnionType, it delegates to Good 👁 tho. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually a better example to highlight the difference would be |
||
## Instances | ||
|
||
### ap | ||
|
||
`Function (a -> b) -> Function b` | ||
`Identity m => m (a -> b) -> m b` | ||
|
||
### chain | ||
|
||
`(a -> m b) -> m b` | ||
`Identity m => (a -> m b) -> m b` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Different types of instance definitions: explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here So as this is specifically an Identity, it could (and maybe should) be written as: Although it would probably look better as: If that makes sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then should all defs be prefixed by the representing monad? |
||
### equals | ||
|
||
`x -> Boolean` | ||
`Identity x => x -> Boolean` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ : does this really need to be defined here or should a top-level api define this? |
||
|
||
### map | ||
|
||
`(a -> b) -> Function b` | ||
`Identity m => m (a -> b) -> Identity m b` | ||
|
||
### of | ||
|
||
`a -> Function a` | ||
`Identity a => a -> Identity a` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should stick with the "shorthand" for 🌽sistancy. Even though this is on the instance for 🌽venience, we do not really need to show the instance, as this function is not dependent on the instance (?)
|
||
|
||
### sequence | ||
|
||
`Type (m a) -> m (Type a)` | ||
`Identity m a => (m a) -> m (Identity a)` | ||
|
||
### traverse | ||
|
||
`a -> Function b -> Function b` | ||
`Identity (a -> m b) => a -> m b -> Identity m b` | ||
|
||
### value | ||
|
||
`a -> a` | ||
`Identity a -> 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.
To expose the constructor and instances defined below to the argument ?