Now that I'm back to using Option I realized I needed another function, project. I also combined this with the recently added (in PR) getAll to get a convenience function, getSubset. It works well, but there are a few possible discussion points I can think of already:
- Is there a way to implement project without resorting to the FFI (the unexported utility function
pickFn)? This is based almost exactly on pickFn from Record-Extra, but an undefined guard is needed here since Foreign.Object can have missing values, whereas a Record cannot. In any case I tried a few things to this end, namely using alter, but ran out of steam trying to massage the types. Denis Stoyanov had this note on Slack, which I'm not sure I follow exactly:
I use it like newtype MyRecord (r :: # Type) = MyRecord (FO.Object (Exists Identity)) but just for example what is record will be
- I'm relying on Records.Extra just to get the
Keys class and related functions, but we might want to reconsider this.
- Of course add docs when the dust settles.
Here is the branch and commit as of this posting.
Now that I'm back to using Option I realized I needed another function,
project. I also combined this with the recently added (in PR)getAllto get a convenience function,getSubset. It works well, but there are a few possible discussion points I can think of already:pickFn)? This is based almost exactly onpickFnfrom Record-Extra, but an undefined guard is needed here since Foreign.Object can have missing values, whereas a Record cannot. In any case I tried a few things to this end, namely usingalter, but ran out of steam trying to massage the types. Denis Stoyanov had this note on Slack, which I'm not sure I follow exactly:Keysclass and related functions, but we might want to reconsider this.Here is the branch and commit as of this posting.