General question: What is the best way to deal with a nested structure where some branch of it…
Joe Grund
1

Good question. You could use `mapped` if the values are already in Maybe’s, but more than likely they are not. Prisms are exactly right for this, but often seem like overkill.

I find myself using the monadic version in most apps:

const safeProp = x => obj => Maybe.fromNullable(obj[x])

safeProp(‘addresses’).chain(safeProp(‘street’)).chain(safeProp(0))

=> Just(‘3’)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.