From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: Composing service definitions (and maybe fmt) Date: Sat, 16 Jan 2016 15:03:59 -0800 Message-ID: <87oacloy61.fsf@dustycloud.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKb42-0002Ms-NE for guix-devel@gnu.org; Sat, 16 Jan 2016 19:19:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKb41-0004VA-4D for guix-devel@gnu.org; Sat, 16 Jan 2016 19:19:26 -0500 Received: from dustycloud.org ([2600:3c02::f03c:91ff:feae:cb51]:36051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKb40-0004V5-Tc for guix-devel@gnu.org; Sat, 16 Jan 2016 19:19:25 -0500 Received: from oolong (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id 53B302673E for ; Sat, 16 Jan 2016 19:19:19 -0500 (EST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org Hello all, So I'm thinking about all the service definitions I'm going to need to put together, and just how many different types of config files there are out there that we're going to need to support, and etc. If we really do produce nice scheme'y config representations for pretty much everything, that's going to be a lot of writers... and there's a big pushback (rightly so) in this group against "stringly typed" formatting systems, so we can't take the Ansible/Salt/etc style jinja2 text formatting style stuff. So what's the plan? It doesn't seem like there's a coherent pattern for doing things between the different services, and some config files are going to be quite complicated to write out. Previously fmt has been mentioned as a possible direction to do string writing without (intermediate) stringly-typed-templateness: http://synthcode.com/scheme/fmt/ I've booted up fmt in guile, it seems it works. Maybe I could package for Guix. It's nice that it uses combinators to do things. Maybe this wouldn't be worth it for all things, but maybe it would be worth it for some things. It may be massive overkill. I don't know. I am impressed by how expressive the writer for javascript is in it... snippet: ;;;; fmt-js.scm -- javascript formatting utilities ;; ;; Copyright (c) 2011-2012 Alex Shinn. All rights reserved. ;; BSD-style license: http://synthcode.com/license.txt ;; ... (define (js-function . x) (let* ((name (and (symbol? (car x)) (car x))) (params (if name (cadr x) (car x))) (body (if name (cddr x) (cdr x)))) (c-block (cat "function " (dsp (or name "")) "(" (fmt-join dsp params ", ") ")") (fmt-let 'return? #t (c-in-stmt (apply c-begin body)))))) (define (js-var . args) (apply c-var 'var args)) (define (js=== . args) (apply c-op "===" args)) ... which could even be nicer with pattern matching, etc. Again, that may be overkill, I don't know! (I've also thought that some sort of string reader similar to skribe's [foo ,(bar)] string-quasiquoting may make things easier. Might even be complimentary...) What do people think? Anyway there's also the concern of fmt as a dependency maybe being tough for some people to get installed. I dunno. I could package fmt for guix though. It might be worth knowing if people think it's worth the time! Alternately, what other direction should we go? I'm a bit nervous to get into services writing right now just because I'm not looking forward to manually string-concatenating and string-joining things... Thoughts? - Chris