Chapter 06: Example Application

The only "new" concept is just theprop function. fp-ts does not provide an equivalent function, but a more powerful library called monocle-ts is recommended for this purpose. There is also a library called fp-ts-ramda which offer this function, among others to help bring feature parity to fp-ts.
I've modified the fp-ts-ramda implementation so it can be used without any additional dependency for the purpose of this book:
book
ts
const prop = curry((property, object) => object[property]);
export function prop<K extends string>(k: K): <T extends Record<K, any>>(obj: T) => T[K];
export function prop<K extends keyof T, T extends object>(k: K, obj: T): T[K];
export function prop<K extends string, T extends Record<K, any>>(k: K, obj?: T): T[K] | ((obj: T) => T[K]) {
if (obj === undefined) {
return <T extends Record<K, any>>(obj: T): T[K] => obj[k];
} else {
return obj[k];
}
}