diff --git a/package-lock.json b/package-lock.json index 8a1d1a5..d2588da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1447,9 +1447,9 @@ } }, "fp-ts": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-1.1.0.tgz", - "integrity": "sha512-nO7q0OfYmPgYmPMxqXzZvEWxaZ0wpNy/fE03IUdW/gdytqNhB0ardbijahmdxFLUVru6vaIUJBBK0DORuf8G+g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-1.2.0.tgz", + "integrity": "sha512-GHUrakKieiz7BWL7eX9G7UMawnaeGSJ1HbZY5t+BbgvzhzgNCT2SXtfqrIl0pRZHkp/oiysdWLMoIxYVlXy66g==", "dev": true }, "fragment-cache": { @@ -5806,9 +5806,9 @@ } }, "typescript": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.1.tgz", - "integrity": "sha512-bqB1yS6o9TNA9ZC/MJxM0FZzPnZdtHj0xWK/IZ5khzVqdpGul/R/EIiHRgFXlwTD7PSIaYVnGKq1QgMCu2mnqw==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.8.1.tgz", + "integrity": "sha512-Ao/f6d/4EPLq0YwzsQz8iXflezpTkQzqAyenTiw4kCUGr1uPiFLC3+fZ+gMZz6eeI/qdRUqvC+HxIJzUAzEFdg==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 5b0e724..66cf281 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "devDependencies": { "@types/jest": "^22.2.0", "dx-lint": "github:devex-web-frontend/dx-lint", - "fp-ts": "^1.1.0", + "fp-ts": "^1.2.0", "jest": "^22.4.2", "jest-cli": "^22.4.2", "prettier": "^1.10.2", @@ -26,10 +26,10 @@ "tslint": "^5.9.1", "tslint-config-prettier": "^1.7.0", "tslint-plugin-prettier": "^1.3.0", - "typescript": "^2.7.1" + "typescript": "^2.8.1" }, "peerDependencies": { - "fp-ts": "^1.1.0", + "fp-ts": "^1.2.0", "tslib": "^1.9.0" }, "dependencies": {}, diff --git a/src/remote-data.ts b/src/remote-data.ts index cb6b491..7f8193d 100644 --- a/src/remote-data.ts +++ b/src/remote-data.ts @@ -17,6 +17,7 @@ import { Ord } from 'fp-ts/lib/Ord'; import { sign } from 'fp-ts/lib/Ordering'; import { Semigroup } from 'fp-ts/lib/Semigroup'; import { Monoid } from 'fp-ts/lib/Monoid'; +import { Monoidal2 } from 'fp-ts/lib/Monoidal'; export const URI = 'RemoteData'; export type URI = typeof URI; @@ -470,6 +471,10 @@ export const isSuccess = (data: RemoteData): data is RemoteSuccess(data: RemoteData): data is RemotePending => data.isPending(); export const isInitial = (data: RemoteData): data is RemoteInitial => data.isInitial(); +//Monoidal +const unit = (): RemoteData => initial; +const mult = (fa: RemoteData, fb: RemoteData): RemoteData => combine(fa, fb); + //Setoid export const getSetoid = (SL: Setoid, SA: Setoid): Setoid> => { return { @@ -551,7 +556,8 @@ export const remoteData: Monad2 & Traversable2 & Alt2 & Extend2 & - Alternative2 = { + Alternative2 & + Monoidal2 = { //HKT URI, @@ -575,6 +581,10 @@ export const remoteData: Monad2 & //Extend extend, + + //Monoidal + unit, + mult, }; export function combine(a: RemoteData): RemoteData;