fp-ts - pipe is deprecated

Viewed 1208

I'm using "fp-ts": "^2.10.5" in my typescript/react project and I'm getting a warning that "pipe" has been deprecated. The code below comes from this tutorial on using fp-ts for error handling and validation:

import { Either, left, right } from 'fp-ts/lib/Either'
import { chain } from 'fp-ts/lib/Either'
import { pipe } from 'fp-ts/lib/pipeable'
//
const minLength = (s: string): Either<string, string> =>
  s.length >= 6 ? right(s) : left('at least 6 characters')

const oneCapital = (s: string): Either<string, string> =>
  /[A-Z]/g.test(s) ? right(s) : left('at least one capital letter')

const oneNumber = (s: string): Either<string, string> =>
  /[0-9]/g.test(s) ? right(s) : left('at least one number')


const validatePassword = (s: string): Either<string, string> =>
  pipe(
    minLength(s),
    chain(oneCapital),
    chain(oneNumber)
  )

The changelog documenting this deprecation states:

deprecate pipeable module, use the specific helpers instead

What are the "specific helpers"? How can I address this warning?

1 Answers

To address this warning import pipe from fp-ts/lib/function instead of fp-ts/lib/pipeable:

import { pipe } from 'fp-ts/lib/function'
Related