Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pick function #5

Open
coot opened this issue Aug 22, 2017 · 6 comments
Open

pick function #5

coot opened this issue Aug 22, 2017 · 6 comments
Labels
purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.

Comments

@coot
Copy link

coot commented Aug 22, 2017

@paf31 would you accept a PR with a pick function, that picks a subrecord from a record.

@MonoidMusician
Copy link

MonoidMusician commented Aug 22, 2017

This looks useful to me!

Regarding your implementation, it would probably be best to implement it in FFI for performance reasons (as unsafePick or something in the Unsafe module).

Oops, commented too early.

But I would also suggest using RProxy r instead of Proxy (Record r), just because you aren't doing anything with the information that it's a record inside the proxy ...

Otherwise it looks good to me, nice suggestion!

@paf31
Copy link
Contributor

paf31 commented Aug 22, 2017

It would need to use the FFI anyway, since I don't really want to add a maps dependency here.

What are the use cases for this?

@coot
Copy link
Author

coot commented Aug 22, 2017

In Redux when you connect a component to a state, and you want to match what you need as tight as possible (which is an optimisation).

Another case how I am using it is when using css-modules and importing css into purescritp through ffi:

foregin import css :: { header :: String, section :: String, footer :: String }

But then a component might just require a section of those css classes.

Sure ffi is the way to go, it's just not accessible in try.purescript :)

@coot
Copy link
Author

coot commented Aug 24, 2017

I guess the right place for the class SubRow is in Type.Row. I'll submit a PR there too.

@coot
Copy link
Author

coot commented Aug 24, 2017

The only dependency that this will introduce is for Data.Array, I hope it's fine. It just requires cons (the new DCE that I am working on is able to cut everything out except the required function :) )

coot pushed a commit to coot/purescript-record that referenced this issue Aug 24, 2017
- `Data.Record.pick` function
- `Data.Record.RowLabels.RowLabels` class

Maybe `RowLabels` class should be somewhere under `Type`.  It depends on
`Array` module (`cons`).
@MonoidMusician
Copy link

Confession: I was originally going to suggest using something like insert/delete, then I realized that wouldn't be any better, hence FFI. My other bad idea was to implement delete in terms of pick 😁 But your PR looks good to me!

@garyb garyb mentioned this issue Jul 22, 2020
@JordanMartinez JordanMartinez added purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump. labels Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.
Projects
None yet
Development

No branches or pull requests

4 participants