Skip to content

TaskEither piping #1422

Answered by 0x706b
nikkonrom asked this question in Q&A
Mar 5, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

The signature of TaskEither<E, A> is () => Promise<Either<E, A>> while the return type of resolveSmaIds is Promise<Either<E, A>>. In other words, TaskEither is a thunked Promise while resolveSmaIds returns a bare Promise. Also, since the Left types are different between the functions, TaskEither.chainW is needed to widen the type on the left.

If you can rewrite resolveSmaIds to return a TaskEither, that would be the “idiomatic” way to do it:

import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'

declare function resolveSmaIds(
  explorationRequest: ExplorationRequest
): TE.TaskEither<ExternalExplorationProviderUnavailable, SmaId[]>

declare function getAllByIds(smaIds

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nikkonrom
Comment options

@centuriononon
Comment options

@samhh
Comment options

Answer selected by nikkonrom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants