3

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?

ANimator120
  • 2,556
  • 1
  • 20
  • 52
  • 1
    `fp-ts/pipeable` module was used to create the pipe-friendly version of functions (see an old version of `Option` for an example: https://github.com/gcanti/fp-ts/blob/583f38b70320ce80023ad10e5a6d1c9e9150f838/src/Option.ts#L701-L722), it has been deprecated for tree-shakeability reasons, if I recall correctly. `pipe` has just been moved from that module to `fp-ts/function`. – Denis Frezzato May 11 '21 at 07:05

1 Answers1

7

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

import { pipe } from 'fp-ts/lib/function'
ANimator120
  • 2,556
  • 1
  • 20
  • 52