[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best practices for writing services
From: |
Xinglu Chen |
Subject: |
Re: Best practices for writing services |
Date: |
Wed, 21 Apr 2021 12:45:21 +0200 |
Hi,
On Tue, Apr 20 2021, Maxim Cournoyer wrote:
> That's a very good question, which I asked myself recently when
> attempting to write my first non-trivial service for Guix
> (jami-daemon-service-type). I'd say 'define-configuration' is
> technically superior because of the automatic type checking it provides.
> It's also neat to be able to define the doc at one place and
> auto-generate it (although that's still manual for now).
You mean that one has to manually evaluate the ‘generate-documentation’
sexp and paste the output of it in the manual? I thought it would
automatically update the manual when running ‘make’. ;)
> It has definitely been collecting some dust compared to the simpler
> approach using 'define-record-type*' directly, and the doc output it
> can generate doesn't match what is currently the norm in the manual,
> so it'd need a bit of a refresh.
Yeah, I noticed that some sections in the manual looked a bit different
than the rest.
One thing that I find a little annoying is that you have to specify a
default value for the fields. This doesn’t make much sense in some
cases, e.g. there is no good default value for ‘user.name = NAME’ in the
Git config, the user should have to specify that themselves.
Another thing is that I don’t always want to “serialize-” the value for a
field, so I sometimes end up defining a bunch of dummy serializers that
just return an empty string.