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

Some real-life examples #1

Open
zverok opened this issue Nov 20, 2019 · 1 comment
Open

Some real-life examples #1

zverok opened this issue Nov 20, 2019 · 1 comment
Assignees

Comments

@zverok
Copy link

zverok commented Nov 20, 2019

Hey! Thanks for the RubyConf talk. Just some real-life examples that I'd probably like to use the gem to, but I can't 😢

require 'kwurry/proc'
JSON.method(:parse).to_proc.kwurry.(symbolize_names: true).('{"a":1,"b":2}')
# ArgumentError (unknown keyword: [:symbolize_names])

# because...
JSON.method(:parse).parameters
# => [[:req, :source], [:opt, :opts]]

# The same way:
File.method(:read).to_proc.kwurry.(mode: 'rb')
# ArgumentError (unknown keyword: [:mode])
File.method(:read).parameters
# => [[:rest]] 

So it is cool to curry "real" kwargs but probably would be much cooler to be able also to curry "imitational" ones.

Thanks nevertheless!

@devpuppy devpuppy self-assigned this Nov 20, 2019
@devpuppy
Copy link
Owner

Thanks for sharing those examples, and very cool that you’d find it useful! There are some issues around functions that mix positional args with kwargs (which is definitely the most common pattern!) and some bugs remain.

I’ll look into addressing those to make this proof-of-concept usable for the real world. And of course the longer term goal is to define a pattern that could become part of Ruby’s implementation of curry.

Thanks for giving it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants