Skip to Content
Mastering JavaScript Functional Programming - Second Edition
book

Mastering JavaScript Functional Programming - Second Edition

by Federico Kereki
January 2020
Intermediate to advanced
470 pages
11h 13m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming - Second Edition

Implementing Prisms

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming

Mastering JavaScript Functional Programming

Federico Kereki

Publisher Resources

ISBN: 9781839213069Supplemental Content