From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id CB2E41F5AE for ; Thu, 23 Jul 2020 00:42:33 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A5F6D120B19; Thu, 23 Jul 2020 09:41:59 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id E0045120A8E for ; Thu, 23 Jul 2020 09:41:56 +0900 (JST) Received: by filterdrecv-p3las1-7754f7d4cc-ln564 with SMTP id filterdrecv-p3las1-7754f7d4cc-ln564-19-5F18DCEE-46 2020-07-23 00:42:23.060594302 +0000 UTC m=+2356132.278579031 Received: from herokuapp.com (unknown) by ismtpd0038p1iad2.sendgrid.net (SG) with ESMTP id eXBxSdbuTiiuupFH8QU67g for ; Thu, 23 Jul 2020 00:42:22.899 +0000 (UTC) Date: Thu, 23 Jul 2020 00:42:23 +0000 (UTC) From: contact@delonnewman.name Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75070 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17043 X-Redmine-Issue-Author: delonnewman X-Redmine-Sender: delonnewman X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?gNS39Mfls23T6mUd1od9trNVAZHJrxR668BMAgjsmX9geA0I=2Flct4GwpGslXp9?= =?us-ascii?Q?6PpQgRxabntDWP+8KfECQMUDJTRPxI5L4MFzRu=2F?= =?us-ascii?Q?74rC3zZLgb=2FPNULsIbepi5Yap+tTKP2F4AodmLR?= =?us-ascii?Q?BE=2Fb3ZSkV2NRvd7u77559TDeiJYhNbKDPSj7vdc?= =?us-ascii?Q?n9oAMhXydfYnC9HkSLlq4x9NbhADrCDuS5lA48R?= =?us-ascii?Q?0cg8qxrQZsgm5YLIw=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99281 Subject: [ruby-core:99281] [Ruby master Feature#17043] Invokable module for custom Proc-like objects X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/