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:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects
Date: Thu, 23 Jul 2020 00:42:23 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-17043.20200723004221.41556@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17043.20200723004221.41556@ruby-lang.org

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/

       reply	other threads:[~2020-07-23  0:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  0:42 contact [this message]
2020-07-23  5:16 ` [ruby-core:99290] [Ruby master Feature#17043] Invokable module for custom Proc-like objects 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

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.issue-17043.20200723004221.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).