Is there a way to filter option types?

I want to know how to filter a type like array<option<t>> into array<t>.

The way I’ve personally tried is Belt.Array.keep((d) => d->Option.isSome)) but it doesn’t work as intended.

Try Belt.Array.keepMap w/ the identity function. That API applies the function to every item and only returns the ones where the result isn’t None.

KeepMap

1 Like