unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Composing service definitions (and maybe fmt)
@ 2016-01-16 23:03 Christopher Allan Webber
  2016-01-19 13:14 ` Ricardo Wurmus
  0 siblings, 1 reply; 11+ messages in thread
From: Christopher Allan Webber @ 2016-01-16 23:03 UTC (permalink / raw)
  To: guix-devel

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-01-24 22:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-16 23:03 Composing service definitions (and maybe fmt) Christopher Allan Webber
2016-01-19 13:14 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).