From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Re: streams are cool, you could stream virtually anything! Date: Thu, 05 Nov 2015 21:08:32 -0500 Message-ID: References: <87ziyuaqhl.fsf@petton.fr> <87fv0labbf.fsf@web.de> <87y4eda0kl.fsf@petton.fr> <8737wl9w5f.fsf@web.de> <87bnb8kd82.fsf@petton.fr> <87wptwirxw.fsf@petton.fr> <877flwl7ee.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446823541 1117 80.91.229.3 (6 Nov 2015 15:25:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2015 15:25:41 +0000 (UTC) Cc: Michael Heerdegen , emacs-devel , bruce.connor.am@gmail.com, raman To: Nicolas Petton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 06 16:25:33 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZuitQ-0001LX-Uy for ged-emacs-devel@m.gmane.org; Fri, 06 Nov 2015 16:25:33 +0100 Original-Received: from localhost ([::1]:39376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuitQ-0004ak-G6 for ged-emacs-devel@m.gmane.org; Fri, 06 Nov 2015 10:25:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuitB-0004aa-OA for emacs-devel@gnu.org; Fri, 06 Nov 2015 10:25:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zuit7-0006y2-Nu for emacs-devel@gnu.org; Fri, 06 Nov 2015 10:25:17 -0500 Original-Received: from mail-vk0-x232.google.com ([2607:f8b0:400c:c05::232]:34596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuit7-0006xy-Jh for emacs-devel@gnu.org; Fri, 06 Nov 2015 10:25:13 -0500 Original-Received: by vkgs66 with SMTP id s66so16351613vkg.1 for ; Fri, 06 Nov 2015 07:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:date:message-id:references :user-agent:mail-followup-to:mime-version:content-type; bh=I2ikNMV1fxCD95Ka+gLOz4ZecU07Xre/AiP0iJRw8nw=; b=VGQ5g7pRNLq2ifo8cOoxVhOCRP5HhqqICXtP8xLuEvQ4eG1EdcKH5Hyg3Tfnq6N5oG D+/dbBmNdGP1lwI8Rlz1di66a/HH/EF6MhliOTU7ue5ivwUdGRm53y7eR5c6RWs4GXMI t5YzcSKyj/tJBbstUCGro8fDVKP2giaH6+L7ZcRsauaky84m5T2e5r45SZzqjkLO1Bdi +bhkARCQfTBqMGvK8Qr/Rnt3rCjC+Bb52bE80XkTTTAsT4wOWAzf8GQo2BRrprz+AgnB YHokvmYhqAzfywOLPPpYeeusjRU+9vhQoDc4S/FgnsurOJlTvUOATzfWY+hvheGtDihv cquA== X-Received: by 10.31.13.11 with SMTP id 11mr14316955vkn.59.1446823513001; Fri, 06 Nov 2015 07:25:13 -0800 (PST) Original-Received: from Hermes-2.local ([216.57.92.130]) by smtp.gmail.com with ESMTPSA id y66sm488005vky.12.2015.11.06.07.25.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 06 Nov 2015 07:25:12 -0800 (PST) X-Google-Original-From: "John Wiegley" Original-Received: by Hermes-2.local (Postfix, from userid 501) id 602DB48EEE5E; Thu, 5 Nov 2015 21:08:36 -0500 (EST) In-Reply-To: <877flwl7ee.fsf@web.de> (Michael Heerdegen's message of "Thu, 05 Nov 2015 17:48:09 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Mail-Followup-To: Nicolas Petton , raman , bruce.connor.am@gmail.com, emacs-devel , Michael Heerdegen X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c05::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:193425 Archived-At: Hi Nicolas, A rich source of ideas could come from looking at the streaming libraries of other languages, like SERIES in Common Lisp, or conduit in Haskell. To give just a few ideas of what might arise from such research: stream-take N STR Produce a stream composed of up to the first N elements of STR. stream-drop N STR Produce a stream starting after the first N elements of STR. stream-cdr = stream-drop 1 stream-apply #'FUNC STR1.. STRN Given a function, reads its arguments from STR1.. STRN, and #'apply the function to those arguments. Its result is the corresponding element of the resulting stream. Continue until one of the argument streams reaches its end. stream-zip = stream-apply #'cons stream-apply* #'FUNC STR1.. STRN Like stream-apply, but any exhausted argument stream is seen to return nil until all are exhausted. stream-iterate FUNC VAL Produce a stream by funcall'ing FUNC on VAL to determine the first element, then funcall FUNC on that result to produce the next element, so on until infinity. stream-isolate N STR Ensure a resulting stream that is exactly N elements long. This is like stream-take if STR is longer, otherwise it's like appending N-M nil values onto STR, where M is the actual length. stream-append STR1 STR2 Concatenate two streams, producing a longer one. stream-loop This is a macro wrapper around `loop' that adds a new keyword: streaming. Like collect, except it collects the results in a stream instead of a list. stream-list LIST Make a list look like a stream (i.e., accessible using the stream API). stream-collect STR Drain all the elements of STR into a list. stream-repeat N VAL A stream consisting of VAL repeated N times. This list could easily be many times as long... For more inspiration see: http://hackage.haskell.org/package/conduit-combinators-1.0.3/docs/Conduit.html If you'd like me continue, just say. I've written libraries similar to this before, just not in Emacs Lisp (and it's awesome that it's becoming easy to!). John