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=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham 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 632381F5AE for ; Thu, 23 Jul 2020 20:57:49 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BA926120B74; Fri, 24 Jul 2020 05:57:15 +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 82CCE120B5C for ; Fri, 24 Jul 2020 05:57:13 +0900 (JST) Received: by filterdrecv-p3iad2-5b55dcd864-n2v2l with SMTP id filterdrecv-p3iad2-5b55dcd864-n2v2l-20-5F19F9C0-7F 2020-07-23 20:57:36.742880173 +0000 UTC m=+2346500.600481598 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-2 (SG) with ESMTP id aX1bf625Suy7a0sZjKpg7A for ; Thu, 23 Jul 2020 20:57:36.722 +0000 (UTC) Date: Thu, 23 Jul 2020 20:57:36 +0000 (UTC) From: contact@delonnewman.name Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75097 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?gNS39Mfls23T6mUd1od9trNVAZHJrxR668BMAgjsmX+I0P8intFPZ2pvWsnuar?= =?us-ascii?Q?i5OUPygl45RoNWBf5t9IuddimG8Ea8F9p2xsLme?= =?us-ascii?Q?FihPdGw1bWJA0yxYWYspsjU50XFMz0jbm+T4r3E?= =?us-ascii?Q?53HJiKMFiM7sbDWzitmDNlrqhOR4HHP9Bop0nTw?= =?us-ascii?Q?j6xyUmrw5Epjek4jBLw=2FsPK9VQTkAKronIMTHtZ?= =?us-ascii?Q?MXzOinx3ZuAcrsth8=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99306 Subject: [ruby-core:99306] [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 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/