Skip to content

Commit

Permalink
Fix flatMap and flatten types
Browse files Browse the repository at this point in the history
  • Loading branch information
paldepind committed Aug 20, 2019
1 parent 4bf9458 commit 68f6039
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export abstract class Component<A, O> implements Monad<O> {
of<P>(p: P): Component<{}, P> {
return new OfComponent(p);
}
flatMap<P>(f: (o: O) => Component<A, P>): Component<A, P> {
flatMap<B, P>(f: (o: O) => Component<B, P>): Component<A, P> {
return new FlatMapComponent(this, f);
}
chain<P>(f: (o: O) => Component<A, P>): Component<A, P> {
chain<B, P>(f: (o: O) => Component<B, P>): Component<A, P> {
return new FlatMapComponent(this, f);
}
output<P>(f: (a: A) => P): Component<A, O & P>;
Expand Down Expand Up @@ -91,7 +91,7 @@ export abstract class Component<A, O> implements Monad<O> {
multi: boolean = false;
abstract run(parent: DomApi, destroyed: Future<boolean>): Out<A, O>;
// Definitions below are inserted by Jabz
flatten: <B>() => Component<O, B>;
flatten: <B, P>(this: Component<A, Component<B, P>>) => Component<A, P>;
map: <P>(f: (a: O) => P) => Component<A, P>;
mapTo: <P>(b: P) => Component<A, P>;
ap: <P>(a: Component<A, (o: O) => P>) => Component<A, P>;
Expand Down Expand Up @@ -177,10 +177,10 @@ export function output<A>(
*/
export const emptyComponent = Component.of({});

class FlatMapComponent<A, O, P> extends Component<A, P> {
class FlatMapComponent<A, O, B, P> extends Component<A, P> {
constructor(
private readonly component: Component<A, O>,
private readonly f: (o: O) => Component<A, P>
private readonly f: (o: O) => Component<B, P>
) {
super();
}
Expand Down

0 comments on commit 68f6039

Please sign in to comment.