DEV Community

Discussion on: Getting started with fp-ts: Reader

Collapse
 
gcanti profile image
Giulio Canti
import { pipe } from 'fp-ts/lib/pipeable' // v2.6
import { chainW, Reader } from 'fp-ts/lib/Reader'

export interface Dependencies {
  readonly i18n: {
    readonly true: string
    readonly false: string
  }
  readonly lowerBound: number
}

export interface OtherDependencies {
  readonly semicolon: boolean
}

declare function transform(a: string): Reader<OtherDependencies, string>
declare function anotherTransform(a: string): Reader<OtherDependencies, string>
declare function f(b: boolean): Reader<Dependencies, string>

const g = (n: number) => pipe(f(n > 2), chainW(transform), chainW(anotherTransform))
Collapse
 
massimilianorango profile image
massimilianorango

That's exactly what I needed. I saw you just released chainW in 2.6.0. Great job thanks! :)