Open anthonyjoeseph opened 2 years ago
As discussed in https://github.com/gcanti/fp-ts/issues/1460#issuecomment-824204261, adding insertAt and renameAt functions to all optics
insertAt
renameAt
const user = { boss: { name: 'Anthony' } } const newUser = { boss: { name: user.name, title: "manager" } } const neighborhood = { house: { dog: 'Rex' } } const newDog = { house: { cat: 'Rex' } }
const newUser = pipe(L.id<typeof user>(), L.prop('boss'), L.insertAt('title', "manager")) // newUser: { boss: { name: string; title: string } } const newDog = pipe(L.id<typeof neighborhood>(), L.prop('house'), L.renameAt('dog', "cat")) // newDog: { house: { cat: string; } }
PLenses (as proposed here https://github.com/gcanti/monocle-ts/issues/59)
Users who want to modify the shape of their data
spectacles-ts as similar functionality, but I wanted to post here as a follow up on this comment from the fp-ts issue tracker https://github.com/gcanti/fp-ts/issues/1460#issuecomment-824204261
the names 'insertAt' and 'renameAt' are analogs to existing functions in the ReadonlyRecord module of fp-ts
🚀 Feature request
As discussed in https://github.com/gcanti/fp-ts/issues/1460#issuecomment-824204261, adding
insertAt
andrenameAt
functions to all opticsCurrent Behavior
Desired Behavior
Suggested Solution
PLenses (as proposed here https://github.com/gcanti/monocle-ts/issues/59)
Who does this impact? Who is this for?
Users who want to modify the shape of their data
Describe alternatives you've considered
spectacles-ts as similar functionality, but I wanted to post here as a follow up on this comment from the fp-ts issue tracker https://github.com/gcanti/fp-ts/issues/1460#issuecomment-824204261
Additional context
the names 'insertAt' and 'renameAt' are analogs to existing functions in the ReadonlyRecord module of fp-ts