From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 2C2771960015 for ; Mon, 29 Jun 2015 17:14:31 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 6026DB5D978 for ; Mon, 29 Jun 2015 17:39:36 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 6AA3697A854 for ; Mon, 29 Jun 2015 17:39:38 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xHrVGiVESiaA for ; Mon, 29 Jun 2015 17:39:38 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id EC40597A848 for ; Mon, 29 Jun 2015 17:39:37 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id B59CD952443 for ; Mon, 29 Jun 2015 17:39:35 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3412512045A; Mon, 29 Jun 2015 17:39:35 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9B975120410 for ; Mon, 29 Jun 2015 17:39:29 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=Qgm13RWtnUKAbxj3CtqrxdqCEhU=; b=qpMqb4DWxuw78vO8Wd znAT05iA7e12bUmSzRUGAOG3CITS/i4QNB726tGp6Gk93HAfLsFVJXcI5F422wW8 JqyWs46A0KtEWjz/n5+6KwZSQPfS/f/5j097+kKcRlKLP6y5nn6VDrBcXbVI+5Pe zt4071HWJ5IsyIAyayuiMz78w= Received: by filter0487p1mdw1.sendgrid.net with SMTP id filter0487p1mdw1.5542.5591043A10 2015-06-29 08:39:23.324930915 +0000 UTC Received: from ismtpd-009.iad1.sendgrid.net ([UNAVAILABLE]. [10.42.2.110]) by 10.42.243.102:2500 (trex/5.2.14); Mon, 29 Jun 2015 08:39:24 GMT Received: from herokuapp.com (ec2-54-89-88-59.compute-1.amazonaws.com [54.89.88.59]) by ismtpd-009 (SG) with ESMTP id 14e3e7885c7.4823.6c4722 Mon, 29 Jun 2015 08:39:22 +0000 (UTC) Date: Mon, 29 Jun 2015 08:39:22 +0000 From: mudge@mudge.name To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Redmine-MailingListIntegration-Message-Ids: 44346 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 6284 X-Redmine-Issue-Author: pabloh X-Redmine-Issue-Assignee: matz X-Redmine-Sender: mudge 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6fR37u2ZTco2tEVLlbMDrovo8jKHpXeSc8im V6vK4inEP/+cCTMVQEng2zHryLOhDoLveRkJSL9RZR7B0RIIcWxtw7TBm1DLcXSvIGsMtHqKUmDbiO +3Wfl+6g1q6fJtxHaq1ERTZi+d1ew1KC3WWg X-ML-Name: ruby-core X-Mail-Count: 69768 Subject: [ruby-core:69768] [Ruby trunk - Feature #6284] Add composition for procs 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #6284 has been updated by Paul Mucur. Regarding the syntax: I also support `*` as the operator where `f * g =3D f= (g(x))` (as it seems close enough to the mathematical syntax already used b= y other languages such as Haskell and Idris) but if that is too divisive, w= e could choose a method name from the mathematical definition (https://en.w= ikipedia.org/wiki/Function_composition) instead: > The notation g=E2=80=89=E2=88=98=E2=80=89f is read as "g circle f ", or "= g round f ", or "g composed with f ", "g after f ", "g following f ", or "g= of f", or "g on f ". This opens up the following options: * `Proc#compose`: `f.compose(g) #=3D> f(g(x))` * `Proc#after`: `f.after(g) #=3D> f(g(x))` * `Proc#following`: `f.following(g) #=3D> f(g(x))` * `Proc#of`: `f.of(g) #=3D> f(g(x))` * `Proc#on`: `f.on(g) #=3D> f(g(x))` ---------------------------------------- Feature #6284: Add composition for procs https://bugs.ruby-lang.org/issues/6284#change-53146 * Author: Pablo Herrero * Status: Feedback * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- =3Dbegin It would be nice to be able to compose procs like functions in functional p= rogramming languages: to_camel =3D :capitalize.to_proc add_header =3D ->val {"Title: " + val} format_as_title =3D add_header << to_camel << :strip instead of: format_as_title =3D lambda {|val| "Title: " + val.strip.capitalize } It's pretty easy to implement in pure ruby: class Proc def << block proc { |*args| self.call( block.to_proc.call(*args) ) } end end =3Dend ---Files-------------------------------- 0002-proc.c-Implement-Method-for-Method-composition.patch (2.71 KB) 0001-proc.c-Implement-Proc-for-Proc-composition.patch (3.73 KB) 0003-proc.c-Support-any-callable-when-composing-Procs.patch (4.01 KB) --=20 https://bugs.ruby-lang.org/