🤖 Merge PR #47648 [sanctuary] Added fromLeft and fromRight definitions for Either by @bratter

* [sanctuary] Add fromLeft and fromRight definitions for Either

* [sanctuary] Added fromLeft and fromRight tests; refactored type expectations for others

* [sanctuary] fixed failing tests
This commit is contained in:
Brendan Ratter 2020-09-16 17:17:24 -07:00 committed by GitHub
parent 194ca3834a
commit 3500e0062b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -222,6 +222,8 @@ declare namespace Sanctuary {
// Either
isLeft(p: Either<any, any>): boolean;
isRight(p: Either<any, any>): boolean;
fromLeft<A>(p: A): (q: Either<A, any>) => A;
fromRight<B>(p: B): (q: Either<any, B>) => B;
fromEither<B>(p: B): (q: Either<any, B>) => B;
either<A, C>(p: Fn<A, C>): <B>(q: Fn<B, C>) => (r: Either<A, B>) => C;
lefts<A>(p: ReadonlyArray<Either<A, any>>): A[];

View File

@ -62,3 +62,9 @@ S.intercalate(', ')([]);
// $ExpectType number[]
S.intercalate([0, 0, 0])([[1], [2, 3], [4, 5, 6], [7, 8], [9]]);
// $ExpectType number
S.fromLeft(1)(S.Right('a'));
// $ExpectType number
S.fromRight(1)(S.Left('a'));