January 2020
Intermediate to advanced
470 pages
11h 13m
English
The more common implementations of Prisms (which we first met in the Prisms section of Chapter 10, Ensuring Purity – Immutability) we came across was that instead of returning either some value or undefined and leaving it up to the caller to check what happened, we could opt to return a Maybe, which already provides us with easy ways to deal with missing values. In our new implementation (which we'll look at soon), our example from the aforementioned chapter would look like this:
const author = { user: "fkereki", name: { first: "Federico", middle: "", last: "Kereki" }, books: [ { name: "GWT", year: 2010 }, { name: "FP", year: 2017 }, { name: "CB", year: 2018 } ]};
If we wanted to access the author.user attribute, the result ...