ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: contact@delonnewman.name
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99306] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
Date: Thu, 23 Jul 2020 20:57:36 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-86695.20200723205736.41556@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17043.20200723004221.41556@ruby-lang.org

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/

      parent reply	other threads:[~2020-07-23 20:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` contact [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-86695.20200723205736.41556@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).