all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Allan Webber <cwebber@dustycloud.org>
To: guix-devel@gnu.org
Subject: Composing service definitions (and maybe fmt)
Date: Sat, 16 Jan 2016 15:03:59 -0800	[thread overview]
Message-ID: <87oacloy61.fsf@dustycloud.org> (raw)

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

             reply	other threads:[~2016-01-17  0:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-16 23:03 Christopher Allan Webber [this message]
2016-01-19 13:14 ` Composing service definitions (and maybe fmt) Ricardo Wurmus
2016-01-19 15:58   ` Christopher Allan Webber
2016-01-20  9:37     ` Ricardo Wurmus
2016-01-20 17:49       ` Christopher Allan Webber
2016-01-20 22:13         ` Ludovic Courtès
2016-01-21 14:12           ` Thompson, David
2016-01-21 21:27             ` Ludovic Courtès
2016-01-21 21:57               ` Christopher Allan Webber
2016-01-24 20:35                 ` Ludovic Courtès
2016-01-24 22:18                   ` Christopher Allan Webber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oacloy61.fsf@dustycloud.org \
    --to=cwebber@dustycloud.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.