Skip to content

Commit

Permalink
Merge pull request #16 from chriskrycho/ergonomic-wins
Browse files Browse the repository at this point in the history
Ergonomics improvements: `value` and `error`.
  • Loading branch information
chriskrycho committed May 18, 2018
2 parents 582c892 + dec0190 commit 904e5b5
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 1,534 deletions.
20 changes: 10 additions & 10 deletions README.md
Expand Up @@ -305,8 +305,8 @@ const transform = _flow(
_.map(Maybe.map(length)),
// drop `Nothing` instances
_.filter(Maybe.isJust),
// unwrap now that it's safe to do so
_.map(Maybe.unsafelyUnwrap),
// get value now that it's safe to do so (TS will not allow earlier)
_.map(maybe => maybe.value),
// only keep the even numbers ('fish' => 4)
_.filter(even),
// multiply by three
Expand Down Expand Up @@ -342,8 +342,8 @@ const transform = _flow(
maybeStrings => _.map(maybeStrings, maybeString => Maybe.map(length, maybeString)),
// drop `Nothing` instances
maybeLengths => _.filter(maybeLengths, Maybe.isJust),
// unwrap now that it's safe to do so
justLengths => _.map(justLengths, Maybe.unsafelyUnwrap),
// get value now that it's safe to do so (TS will not allow earlier)
justLengths => _.map(justLengths, maybe => maybe.value),
// only keep the even numbers ('fish' => 4)
lengths => _.filter(lengths, even),
// multiply by three
Expand Down Expand Up @@ -817,8 +817,8 @@ In many cases, you can simple rename your imports and some of the function invoc

- [ ] TODO: rest of the migration path from Folktale 2.0

| Folktale | True Myth | Notes |
|------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Folktale | True Myth | Notes |
| ---------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Maybe` | `Maybe ` | |
| `Maybe.hasInstance` | no equivalent | |
| `Maybe.empty` | `Maybe.nothing` | |
Expand All @@ -839,8 +839,8 @@ In many cases, you can simple rename your imports and some of the function invoc
| `Nothing#type` | no equivalent | |
| `Just#concat` | no equivalent | |
| `Nothing#concat` | no equivalent | |
| `Just#equals` | no equivalent | Consider using e.g. [`_.isEqual`] or [`R.equals`] |
| `Nothing#equals` | no equivalent | Consider using e.g. [`_.isEqual`] or [`R.equals`] |
| `Just#equals` | `Just#equals` | You can also use the static method `Maybe.equals` |
| `Nothing#equals` | `Nothing#equals` | You can also use the static method `Maybe.equals` |
| `Result` | `Result` | |
| `Validation` | no equivalent | You can use `Result` instead: a `Validation<Success, Failure>` has identical semantics to `Result<T, E>` |

Expand All @@ -851,8 +851,8 @@ In many cases, you can simple rename your imports and some of the function invoc

There are straightforward conversions from most Sanctuary functions to True Myth functions.

| Sanctuary | True Myth | Notes |
|-------------|------------|-------|
| Sanctuary | True Myth | Notes |
| ----------- | ---------- | ----- |
| `S.Either` | `Result` | |
| `Left` | `Err` | |
| `Right` | `Ok` | |
Expand Down
4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -14,7 +14,7 @@
"bugs": {
"url": "https://github.com/chriskrycho/true-myth/issues"
},
"version": "1.2.0",
"version": "1.3.0",
"main": "dist/commonjs/src/index.js",
"module": "dist/modules/src/index.js",
"types": "dist/types/src/index.d.ts",
Expand All @@ -31,7 +31,6 @@
"scripts": {
"clean": "rimraf dist",
"doc": "./scripts/build-docs",
"precommit": "./scripts/build-docs && git add docs",
"problems": "node ./scripts/problems.js",
"preversion": "yarn run test && yarn run prepack",
"prepack": "ember build -prod && cp ./src/flow/* ./dist/modules/src && cp ./src/flow/* ./dist/commonjs/src",
Expand All @@ -44,7 +43,6 @@
"@types/jest": "^22.1.1",
"ember-cli": "^2.18.2",
"flow-bin": "^0.64.0",
"husky": "^0.14.3",
"jest": "^22.1.4",
"libkit": "^0.5.17",
"prettier": "^1.10.2",
Expand Down
8 changes: 3 additions & 5 deletions src/index.ts
Expand Up @@ -4,8 +4,6 @@
*/

/** (keep typedoc from getting confused by the imports) */
import Maybe from './maybe';
import Result from './result';
import Unit from './unit';

export { Maybe, Result, Unit };
export { default as Maybe } from './maybe';
export { default as Result } from './result';
export { default as Unit } from './unit';

0 comments on commit 904e5b5

Please sign in to comment.