diff --git a/.gitignore b/.gitignore
index fa2dbf2..25312c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ node_modules/
dist/
.*.swp
yarn-error.log
+.vscode/
diff --git a/package.json b/package.json
index 58568ac..e3d139f 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,8 @@
"version": "1.6.5",
"description": "",
"license": "MIT",
- "main": "lib/index.js",
- "typings": "lib/index.d.ts",
+ "main": "dist/index.js",
+ "typings": "dist/index.d.ts",
"author": {
"name": "Paul Gray",
"email": "pfbgray@gmail.com",
@@ -15,7 +15,7 @@
"lint-fix": "tslint --project tsconfig-build.json --fix",
"docs:gitbook": "gitbook build ./ docs",
"docs:typedoc": "typedoc --module commonjs --out docs/typedoc/ src/",
- "build": "npm-run-all clean build:ts build:dist docs:gitbook",
+ "build": "npm-run-all clean build:ts build:dist",
"build:ts": "tsc -p tsconfig-build.json",
"build:dist": "webpack --config webpack/bundle.ts",
"clean": "rm -rf lib/",
@@ -65,12 +65,15 @@
"ts-node": "^3.3.0",
"tslint": "^5.7.0",
"typedoc": "^0.11.1",
- "typescript": "^2.5.3",
+ "typescript": "^3.4.0",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.3",
"webpack-dev-server": "^3.1.4"
},
- "dependencies": {},
+ "dependencies": {
+ "fp-ts": "^1.15.0",
+ "fp-ts-contrib": "^0.0.2"
+ },
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0"
},
diff --git a/src/index.ts b/src/index.ts
index 7dd6142..dc627c0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -10,6 +10,7 @@ import {
import { withPromise, WithPromise } from './lib/withPromise';
import { withState, WithState } from './lib/withState';
import { withLifecycle, WithLifecycle } from './lib/withLifecycle';
+import { chainableComponent, DoBuilder } from './lib/fpts';
export {
ChainableComponent,
@@ -24,5 +25,7 @@ export {
withPromise,
WithPromise,
withLifecycle,
- WithLifecycle
+ WithLifecycle,
+ chainableComponent,
+ DoBuilder
};
diff --git a/src/lib/fpts.ts b/src/lib/fpts.ts
new file mode 100644
index 0000000..b66407a
--- /dev/null
+++ b/src/lib/fpts.ts
@@ -0,0 +1,31 @@
+import { Monad1 } from "fp-ts/lib/Monad";
+import { HKT } from 'fp-ts/lib/HKT';
+import { ChainableComponent } from "..";
+import { Do } from 'fp-ts-contrib/lib/Do';
+
+export const URI = "ChainableComponent";
+export type URI = typeof URI;
+
+declare module "fp-ts/lib/HKT" {
+ interface URI2HKT {
+ ChainableComponent: ChainableComponent;
+ }
+}
+
+export const chainableComponent: Monad1 = {
+ URI,
+ of(a: A) {
+ return ChainableComponent.of(a);
+ },
+ map(fa: ChainableComponent, f: (a: A) => B) {
+ return fa.map(f);
+ },
+ ap(fab: ChainableComponent<(a: A) => B>, fa: ChainableComponent) {
+ return fa.ap(fab)
+ },
+ chain(fa: ChainableComponent, f: (a: A) => ChainableComponent) {
+ return fa.chain(f)
+ }
+};
+
+export const DoBuilder = Do(chainableComponent)
diff --git a/tsconfig.json b/tsconfig.json
index fb11189..894f995 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,13 +2,12 @@
"compileOnSave": false,
"compilerOptions": {
"declaration": true,
- "experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
- "noUnusedLocals": true,
+ "noUnusedLocals": false,
"noUnusedParameters": true,
"target": "es5",
"sourceMap": true,
diff --git a/yarn.lock b/yarn.lock
index ce0675e..b2dabce 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -81,6 +81,10 @@
version "10.3.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.3.5.tgz#8423cdf6e6fb83433e489900d7600d3b61c8260c"
+"@types/prop-types@*":
+ version "15.7.0"
+ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.0.tgz#4c48fed958d6dcf9487195a0ef6456d5f6e0163a"
+
"@types/ramda@^0.25.36":
version "0.25.36"
resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.25.36.tgz#1ddaf3211c7cd7046fcaefe68c713469ccfc9504"
@@ -105,12 +109,19 @@
"@types/history" "*"
"@types/react" "*"
-"@types/react@*", "@types/react@^16.0.10":
+"@types/react@*":
version "16.4.1"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.1.tgz#c53bbfb4a78933db587da085ac60dbf5fcf73f8f"
dependencies:
csstype "^2.2.0"
+"@types/react@^16.0.10":
+ version "16.8.10"
+ resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.10.tgz#1ccb6fde17f71a62ef055382ec68bdc379d4d8d9"
+ dependencies:
+ "@types/prop-types" "*"
+ csstype "^2.2.0"
+
"@types/recompose@^0.26.4":
version "0.26.4"
resolved "https://registry.yarnpkg.com/@types/recompose/-/recompose-0.26.4.tgz#93dd6c4e28857cd799e9a807a470f66a40c49c3f"
@@ -2102,6 +2113,16 @@ forwarded@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
+fp-ts-contrib@^0.0.2:
+ version "0.0.2"
+ resolved "https://learningobjects.jfrog.io/learningobjects/api/npm/npm-virtual/fp-ts-contrib/-/fp-ts-contrib-0.0.2.tgz#95d3f5a3810020f8aea030bfcbd1efabbfb8124e"
+ dependencies:
+ fp-ts "^1.14.3"
+
+fp-ts@^1.14.3, fp-ts@^1.15.0:
+ version "1.15.0"
+ resolved "https://learningobjects.jfrog.io/learningobjects/api/npm/npm-virtual/fp-ts/-/fp-ts-1.15.0.tgz#7706d6761cc98ccbece91c2ff2e5a5b924f65f3d"
+
fragment-cache@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19"
@@ -5540,9 +5561,9 @@ typescript@2.7.2:
version "2.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"
-typescript@^2.5.3:
- version "2.9.2"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
+typescript@^3.4.0:
+ version "3.4.1"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.1.tgz#b6691be11a881ffa9a05765a205cb7383f3b63c6"
ua-parser-js@^0.7.18:
version "0.7.18"