From: contact@... Date: 2020-07-23T20:57:36+00:00 Subject: [ruby-core:99306] [Ruby master Feature#17043] Invokable module for custom Proc-like objects 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/ Unsubscribe: