guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A new paradigm for modifying operating system declarations


From: Taylan Kammer
Subject: Re: A new paradigm for modifying operating system declarations
Date: Mon, 4 Jan 2021 21:21:20 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 04.01.2021 16:38, raid5atemyhomework wrote:
Hi guix-developers,

I'd like to propose an idea for constructing `<operating-system>` objects.

[... snip ...]

What are your opinions?  Blech?  Yummy?  Is it worth exploring this paradigm 
for adding particularly complex features to an operating system definition?

Hi,

Interesting idea.

First, let me point out a more conventional alternative to what your 'decorate' macro does:

  (define (compose proc . rest)
    "Functional composition; e.g. ((compose x y) a) = (x (y a))."
    (if (null? rest)
        proc
        (let ((rest-proc (apply compose rest)))
          (lambda x
            (let-values ((x (apply rest-proc x)))
              (apply proc x))))))

This allows for something like:

  ((compose install-foo install-bar install-zfs)
   (operating-system ...))

Or perhaps cleaner:

  (define my-os-modifier (compose install-foo install-bar install-zfs))

  (my-os-modifier
   (operating-system ...))

If you need custom modifications within, you can do:

  (define my-os-modifier
    (compose install-foo
             (lambda (os) ...)
             install-bar))

It's more verbose, but doesn't "break" standard Scheme syntax as much. Function composition is conceptually pretty easy and probably more well-known than "decorators" (which I had never heard of, personally).

Fewer macros means the reader needs to keep fewer special rules in mind.

---

Secondly, I wonder if passing an OS declaration through various procedures that modify it is really the best approach in the first place.

For build phases, we have the 'modify-phases' syntax. For services, there is 'modify-services'. Maybe there should be a 'modify-os' kind of syntax. (In other words, if we're going to invent new syntax, why not go all-out and create the most convenient syntax for the use-case.)

Just my thoughts.


- Taylan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]