Effect CommunityEC
Effect Community3y ago
14 replies
bigpopakap

Adding a `Data.evolve()` function for updating data structures

Could we please add a Data.evolve() function? I find myself doing something like this a lot:

interface Person extends Data.Case {
   name: string;
   age: number;
}

pipe(
    // ... Some person ...
   Struct.evolve({ age: add1 }),
   // ... Now they're a year older
   // but I've lost the Equals and Hash methods
   Data.struct, // get back the Equals and Hash
)

... Though, sorry, I have two caveats:
- I've been holding back this question for a while, so I'm not sure if this is still the case
- maybe this code doesn't compile... I'm on my phone
Was this page helpful?