Skip to content

Commit

Permalink
feat: update to [email protected], [email protected] + implement Monoidal
Browse files Browse the repository at this point in the history
  • Loading branch information
raveclassic committed Sep 25, 2018
1 parent d3ac781 commit d9a4a09
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {},
Expand Down
12 changes: 11 additions & 1 deletion src/remote-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -470,6 +471,10 @@ export const isSuccess = <L, A>(data: RemoteData<L, A>): data is RemoteSuccess<L
export const isPending = <L, A>(data: RemoteData<L, A>): data is RemotePending<L, A> => data.isPending();
export const isInitial = <L, A>(data: RemoteData<L, A>): data is RemoteInitial<L, A> => data.isInitial();

//Monoidal
const unit = <L, A>(): RemoteData<L, A> => initial;
const mult = <L, A, B>(fa: RemoteData<L, A>, fb: RemoteData<L, B>): RemoteData<L, [A, B]> => combine(fa, fb);

//Setoid
export const getSetoid = <L, A>(SL: Setoid<L>, SA: Setoid<A>): Setoid<RemoteData<L, A>> => {
return {
Expand Down Expand Up @@ -551,7 +556,8 @@ export const remoteData: Monad2<URI> &
Traversable2<URI> &
Alt2<URI> &
Extend2<URI> &
Alternative2<URI> = {
Alternative2<URI> &
Monoidal2<URI> = {
//HKT
URI,

Expand All @@ -575,6 +581,10 @@ export const remoteData: Monad2<URI> &

//Extend
extend,

//Monoidal
unit,
mult,
};

export function combine<A, L>(a: RemoteData<L, A>): RemoteData<L, [A]>;
Expand Down

0 comments on commit d9a4a09

Please sign in to comment.