G
Size: a a a
G
G
К
class MaybeJust<+T> implements Maybe<T> {
tap(call: T => any): Maybe<T> {
call(getValue(this));
return this;
}
...
}
class MaybeNothing<+T> implements Maybe<T> {
tap() {
return nothing;
}
...
}
maybe.tap(v => console.log(`this is Just(${v})`));
class EitherRight<+L, +R> implements Either<L, R> {
tapR(call: R => any): Either<L, R> {
call(getRight(this));
return this;
}
tapL(): Either<L, R> {
return this;
}
}
class EitherLeft<+L, +R> implements Either<L, R> {
tapR(): Either<L, R> {
return this;
}
tapL(call: L => any): Either<L, R> {
call(getLeft(this));
return this;
}
}
either
.tapR(v => console.log(`this is Right(${v})`))
.tapL(v => console.log(`this is Left(${v})`));
G
class MaybeJust<+T> implements Maybe<T> {
tap(call: T => any): Maybe<T> {
call(getValue(this));
return this;
}
...
}
class MaybeNothing<+T> implements Maybe<T> {
tap() {
return nothing;
}
...
}
maybe.tap(v => console.log(`this is Just(${v})`));
class EitherRight<+L, +R> implements Either<L, R> {
tapR(call: R => any): Either<L, R> {
call(getRight(this));
return this;
}
tapL(): Either<L, R> {
return this;
}
}
class EitherLeft<+L, +R> implements Either<L, R> {
tapR(): Either<L, R> {
return this;
}
tapL(call: L => any): Either<L, R> {
call(getLeft(this));
return this;
}
}
either
.tapR(v => console.log(`this is Right(${v})`))
.tapL(v => console.log(`this is Left(${v})`));
К
К
К
G
К
G
class MaybeJust<+T> implements Maybe<T> {
tap(call: T => any): Maybe<T> {
call(getValue(this));
return this;
}
...
}
class MaybeNothing<+T> implements Maybe<T> {
tap() {
return nothing;
}
...
}
maybe.tap(v => console.log(`this is Just(${v})`));
class EitherRight<+L, +R> implements Either<L, R> {
tapR(call: R => any): Either<L, R> {
call(getRight(this));
return this;
}
tapL(): Either<L, R> {
return this;
}
}
class EitherLeft<+L, +R> implements Either<L, R> {
tapR(): Either<L, R> {
return this;
}
tapL(call: L => any): Either<L, R> {
call(getLeft(this));
return this;
}
}
either
.tapR(v => console.log(`this is Right(${v})`))
.tapL(v => console.log(`this is Left(${v})`));
К
К
К
G
К
К
either
.mapR(v => 'this is Right ' + v)
.mapL(v => 'this is Left ' + v)
.tapR(console.log)
.tapL(console.log);
G
К
G
G