From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:46776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyaWK-0006Kb-0r for gwl-devel@gnu.org; Mon, 03 Feb 2020 07:08:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyaWI-0001aO-Hj for gwl-devel@gnu.org; Mon, 03 Feb 2020 07:08:03 -0500 References: <871rrdthmz.fsf@elephly.net> From: Ricardo Wurmus Subject: Re: Comments on process template syntax In-reply-to: Date: Mon, 03 Feb 2020 13:07:29 +0100 Message-ID: <87lfpjswla.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gwl-devel-bounces+kyle=kyleam.com@gnu.org Sender: "gwl-devel" To: Roel Janssen Cc: gwl-devel@gnu.org Hi Roel, > On Sun, 2020-02-02 at 11:20 +0100, Ricardo Wurmus wrote: >> Hi, >> >> While looking at the examples at >> https://www.guixwl.org/beyond-started, >> I found that process templates might be difficult to understand, and >> that they have no pretty syntax. >> >> --8<---------------cut here---------------start------------->8--- >> process: (list-file-template filename) >> name >> string-append "list-file-" >> basename filename >> packages "gzip" >> inputs filename >> outputs >> string-append filename ".list" >> run-time >> complexity >> space 20 mebibytes >> time 30 seconds >> # { gzip --list {{inputs}} > {{outputs}} } >> --8<---------------cut here---------------end--------------->8--- >> >> The first line is easy to understand for lispers but it might look >> weird >> to people who come from other workflow languages or programming >> languages. This describes a procedure called =E2=80=9Clist-file-templat= e=E2=80=9D >> that >> returns a process parameterized on the argument =E2=80=9Cfilename=E2=80= =9D. >> >> Nextflow has no concept of procedures that produce processes when >> given >> arguments. It does however have a concept of data streams that can >> be >> fed into processes, which results in a process to be instantiated for >> every element of the stream. The stream may be created from a >> directory >> containing files. >> >> This implementation likely stems from the realization that the >> =E2=80=9Ctemplate >> case=E2=80=9D is the most common case for processes. Rarely ever is it >> necessary to define a process that does *not* require >> parameterization >> on its inputs. >> >> Can we make the common case simpler and easier to understand? > > Perhaps with some parentheses? That it is a Lisp is a good thing, not > something you'd rather hide.. :) Like you've said; what you've defined > above is a procedure, not a record. That's a really cool "feature" of > the GWL! I agree. I wouldn=E2=80=99t want to hide it e.g. by somehow =E2=80=9Cinfer= ring=E2=80=9D procedure inputs via the inputs field. I think it=E2=80=99s good that it closely resembles a procedure, because that=E2=80=99s what it is. I still think that the syntax is sub-optimal. We support Wisp to make the Lispiness a little easier to swallow for the skeptics. But the procedure case does not benefit much from Wisp =E2=80=94 it would look = worse if we expressed it in the Wisp way: process : list-file-template filename Note the space between =E2=80=9Cprocess=E2=80=9D and the remainder. It wou= ld be wrong to remove the space after =E2=80=9Cprocess=E2=80=9D. That=E2=80=99s a pitf= all stemming from a familiarity with YAML that I=E2=80=99d rather avoid. (That=E2=80=99s why I= want to rename =E2=80=9Cprocess:=E2=80=9D and =E2=80=9Cworkflow:=E2=80=9D.) The only reason why I know how to use =E2=80=9C:=E2=80=9D is because I know= that I want the remainder to be wrapped in parentheses=E2=80=A6 People who only know t= he sugary syntax would not have that knowledge and it would just seem like an arbitrary thing. The confusion disappears in my opinion when the colon does not follow the first word. process list-file-template : filename name =E2=80=A6 inputs =E2=80=A6 outputs =E2=80=A6 or when the colon is avoided altogether: process list-file-template (filename) name =E2=80=A6 inputs =E2=80=A6 outputs =E2=80=A6 or in Lispy syntax (process list-file-template (filename) (name =E2=80=A6) (inputs =E2=80=A6) (outputs =E2=80=A6)) Having a list of identifiers after the name of the procedure matches Common Lisp and C-style languages. I think it looks less confusing as the difference between the =E2=80=9Ctemplate case=E2=80=9D and the =E2=80= =9Crecord case=E2=80=9D becomes merely a parenthetical list of free variables. What do you think? This can be accomplished with a tiny change to the =E2=80=9Cprocess=E2=80=9D macro in (gwl sugar). > Maybe we can just clarify the feature better in the documentation. > Here's my initial thought: > --- > When defining processes, they can be parameterized by turning the > process definition into a procedure, which will form a template for > processes to be defined later. This is done by adding a name for the > template, and its parameters directly after "process:". > --- I agree that emphasizing this in the manual is a good idea. -- Ricardo