jaredly / jaredly/get_in_ppx

Filter optional arrays/lists?

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Reason
Stars
40
Forks
3
PR merge metrics
No merged PRs in 30d

Description

It's very common to have an array/list of optional items, and to use `get_in` to get the list and then filter out the `None`s. The boilerplate ends up being pretty miserable.

In the same spirit as the current operators, it'd be nice to be able to have an operator that would filter out nullable items, e.g.:

```reason
let data = Some({"gitHub": Some({"user": Some({"repositories": Some({"nodes": Some([None, None, Some({"id": "a"})])})})})});

let repos = gitHub#??user#?repositories#nodes!!
// repos = [{"id": "a"}];
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the implementation and tests for the existing operators referenced in the issue. Compare their behavior with the nested optional-list example, then define the operator's expected handling of None values and verify that the example produces only the non-null repository item.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.