ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
@ 2020-07-23  0:42 contact
  2020-07-23  5:16 ` [ruby-core:99290] " shyouhei
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: contact @ 2020-07-23  0:42 UTC (permalink / raw)
  To: ruby-core

Issue #17043 has been reported by delonnewman (Delon Newman).

----------------------------------------
Feature #17043: Invokable module for custom Proc-like objects 
https://bugs.ruby-lang.org/issues/17043

* Author: delonnewman (Delon Newman)
* Status: Open
* Priority: Normal
----------------------------------------
Ruby beautifully integrates Functional and Object-Oriented Programming, and there's more moving in the direction of supporting Functional Programming. A generalization of the Proc interface would enable users to integrate a functional approach into their classic OOP design patterns. One of the obvious examples would be "Command" objects.

Also, generic structures which Ruby as great support for. Hash now has `to_proc`.  But, it'd be great to be able to treat sets as predicate functions.

I've put together a prototype that I've found useful in my own work here: https://github.com/delonnewman/invokable.

It works like Enumerable, it can be included in any class that implements a `call` method. Then you get `to_proc`, `curry`, `<<` and `>>` for right and left composition, and `memoize`. More could be added. If you include `Invokable::Command` you can treat your "Command" object as an automatically curried function.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:99290] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
  2020-07-23  0:42 [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects contact
@ 2020-07-23  5:16 ` shyouhei
  2020-07-23 18:19 ` [ruby-core:99302] " contact
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: shyouhei @ 2020-07-23  5:16 UTC (permalink / raw)
  To: ruby-core

Issue #17043 has been updated by shyouhei (Shyouhei Urabe).

Status changed from Open to Feedback

While your library seems great, what is proposed in this ticket is not that obvious.  How can we help?  What can we do?

----------------------------------------
Feature #17043: Invokable module for custom Proc-like objects 
https://bugs.ruby-lang.org/issues/17043#change-86679

* Author: delonnewman (Delon Newman)
* Status: Feedback
* Priority: Normal
----------------------------------------
Ruby beautifully integrates Functional and Object-Oriented Programming, and there's more moving in the direction of supporting Functional Programming. A generalization of the Proc interface would enable users to integrate a functional approach into their classic OOP design patterns. One of the obvious examples would be "Command" objects.

Also, generic structures which Ruby as great support for. Hash now has `to_proc`.  But, it'd be great to be able to treat sets as predicate functions.

I've put together a prototype that I've found useful in my own work here: https://github.com/delonnewman/invokable.

It works like Enumerable, it can be included in any class that implements a `call` method. Then you get `to_proc`, `curry`, `<<` and `>>` for right and left composition, and `memoize`. More could be added. If you include `Invokable::Command` you can treat your "Command" object as an automatically curried function.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:99302] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
  2020-07-23  0:42 [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects contact
  2020-07-23  5:16 ` [ruby-core:99290] " shyouhei
@ 2020-07-23 18:19 ` contact
  2020-07-23 18:43 ` [ruby-core:99303] " marcandre-ruby-core
  2020-07-23 20:57 ` [ruby-core:99306] " contact
  3 siblings, 0 replies; 5+ messages in thread
From: contact @ 2020-07-23 18:19 UTC (permalink / raw)
  To: ruby-core

Issue #17043 has been updated by delonnewman (Delon Newman).


Yeah, I guess I wasn't as clear. I'm curious if an officially blessed "Invokable" module might be a useful thing for the standard library. I obviously don't have the perspective you do.

----------------------------------------
Feature #17043: Invokable module for custom Proc-like objects 
https://bugs.ruby-lang.org/issues/17043#change-86690

* Author: delonnewman (Delon Newman)
* Status: Feedback
* Priority: Normal
----------------------------------------
Ruby beautifully integrates Functional and Object-Oriented Programming, and there's more moving in the direction of supporting Functional Programming. A generalization of the Proc interface would enable users to integrate functional approach into their classic OOP design patterns. One of the obvious examples would be "Command" objects.

Also, generic structures, which Ruby has great support for. Hash now has `to_proc`.  But, it'd be great to be able to treat sets as predicate functions.

I've put together a prototype that I've found useful in my own work here: https://github.com/delonnewman/invokable.

It works like Enumerable; it can be included in any class that implements a `call` method. Then you get `to_proc`, `curry`, `<<` and `>>` for right and left composition, and `memoize`. More could be added. If you include `Invokable::Command`, you can treat your "Command" object as an automatically curried function.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:99303] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
  2020-07-23  0:42 [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects contact
  2020-07-23  5:16 ` [ruby-core:99290] " shyouhei
  2020-07-23 18:19 ` [ruby-core:99302] " contact
@ 2020-07-23 18:43 ` marcandre-ruby-core
  2020-07-23 20:57 ` [ruby-core:99306] " contact
  3 siblings, 0 replies; 5+ messages in thread
From: marcandre-ruby-core @ 2020-07-23 18:43 UTC (permalink / raw)
  To: ruby-core

Issue #17043 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Feedback to Rejected

>  But, it'd be great to be able to treat sets as predicate functions

Note that since Ruby 2.5, `Set#===` is an alias for `include?`, so you can do `ary.grep(Set[...])` for example.

> I'm curious if an officially blessed "Invokable" module might be a useful thing for the standard library.

Most of the standard library is being made available as separate gems (or removed altogether), so we're basically trying to reduce the standard library, not extend it. Thanks for enquiring though.

----------------------------------------
Feature #17043: Invokable module for custom Proc-like objects 
https://bugs.ruby-lang.org/issues/17043#change-86691

* Author: delonnewman (Delon Newman)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ruby beautifully integrates Functional and Object-Oriented Programming, and there's more moving in the direction of supporting Functional Programming. A generalization of the Proc interface would enable users to integrate functional approach into their classic OOP design patterns. One of the obvious examples would be "Command" objects.

Also, generic structures, which Ruby has great support for. Hash now has `to_proc`.  But, it'd be great to be able to treat sets as predicate functions.

I've put together a prototype that I've found useful in my own work here: https://github.com/delonnewman/invokable.

It works like Enumerable; it can be included in any class that implements a `call` method. Then you get `to_proc`, `curry`, `<<` and `>>` for right and left composition, and `memoize`. More could be added. If you include `Invokable::Command`, you can treat your "Command" object as an automatically curried function.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:99306] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
  2020-07-23  0:42 [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects contact
                   ` (2 preceding siblings ...)
  2020-07-23 18:43 ` [ruby-core:99303] " marcandre-ruby-core
@ 2020-07-23 20:57 ` contact
  3 siblings, 0 replies; 5+ messages in thread
From: contact @ 2020-07-23 20:57 UTC (permalink / raw)
  To: ruby-core

Issue #17043 has been updated by delonnewman (Delon Newman).


Got it, that make sense. But, just to be clear my proposal is not to include my module in the standard library, but to include a module that would generalize the notion of a Proc. Which could potentially simplify a great many things. Perhaps sometime in the future.

Thank you for your consideration and the tip on `Set#===`. I'd never used it with grep.

----------------------------------------
Feature #17043: Invokable module for custom Proc-like objects 
https://bugs.ruby-lang.org/issues/17043#change-86695

* Author: delonnewman (Delon Newman)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ruby beautifully integrates Functional and Object-Oriented Programming, and there's more moving in the direction of supporting Functional Programming. A generalization of the Proc interface would enable users to integrate functional approach into their classic OOP design patterns. One of the obvious examples would be "Command" objects.

Also, generic structures, which Ruby has great support for. Hash now has `to_proc`.  But, it'd be great to be able to treat sets as predicate functions.

I've put together a prototype that I've found useful in my own work here: https://github.com/delonnewman/invokable.

It works like Enumerable; it can be included in any class that implements a `call` method. Then you get `to_proc`, `curry`, `<<` and `>>` for right and left composition, and `memoize`. More could be added. If you include `Invokable::Command`, you can treat your "Command" object as an automatically curried function.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-23 20:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23  0:42 [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects contact
2020-07-23  5:16 ` [ruby-core:99290] " shyouhei
2020-07-23 18:19 ` [ruby-core:99302] " contact
2020-07-23 18:43 ` [ruby-core:99303] " marcandre-ruby-core
2020-07-23 20:57 ` [ruby-core:99306] " contact

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).