GNU bug report logs - #36555
[PATCH 0/2] Refactor out common behavior for system reconfiguration.

Previous Next

Package: guix-patches;

Reported by: zerodaysfordays <at> sdf.lonestar.org (Jakob L. Kreuze)

Date: Mon, 8 Jul 2019 19:53:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #160 received at 36555-done <at> debbugs.gnu.org (full text, mbox):

From: zerodaysfordays <at> sdf.lonestar.org (Jakob L. Kreuze)
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 36555-done <at> debbugs.gnu.org
Subject: Re: [bug#36555] [PATCH v6 3/3] tests: Add reconfigure system test.
Date: Fri, 26 Jul 2019 13:53:03 -0400
[Message part 1 (text/plain, inline)]
Hi Ludo,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi there!
>
> I’ve applied the whole series with the change below.  \o/

Awesome, thank you!

> Because of the monadic style, the ‘guard’ clause had no effect:
>
> scheme@(guile-user)> ,run-in-store (guard (c (#t 'caught)) (mbegin %store-monad (return 1)(return (raise (condition (&message (message "oh!")))))))
> While executing meta-command:
> Throw to key `srfi-34' with args `(#<condition &message [message: "oh!"] 1cab2c0>)'.

My thoughts were similar when I was working on earlier versions of this
series, so I had devised the following snippet:

[example.scm (text/plain, inline)]
(use-modules (guix monads)
             (guix store)
             (srfi srfi-34)
             (srfi srfi-35))

(define (monadic-procedure)
  (catch #t
    (lambda ()
      (guard (c ((message-condition? c)
                 (format (current-error-port) "error: ~a~%"
                         (condition-message c))
                 (throw c)))
        (mbegin %store-monad
          (return (raise (condition (&message (message "Bogus error"))))))))
    (lambda _
      (mbegin %store-monad
        (return (format #t "Error was caught~%"))))))

(with-store store
  (run-with-store store
    (monadic-procedure)))
[Message part 3 (text/plain, inline)]
Which, when run, outputs the following:

jakob <at> Epsilon ~ $ guile example.scm
error: Bogus error
Error was caught

I have a fairly weak understanding of monads, how they're implemented in
Guix, and how exception handling works in Guile, so I'm not entirely
sure why one example works and the other doesn't. Either way,

> I thought about adding it in some other way, but it turns out not to
> be needed at all because error conditions are guarded against in
> ‘guix-system’. Hence the patch.

I suppose that, in that case, we don't really need to worry about it.

> Thank you for the hard work on this series!

And thank you for all of the code review you've done :)

> I’ll be away from keyboard roughly until August 17th. Hopefully you
> can get feedback from David or Chris, and maybe you can get others on
> board as well. :-) If my opinion on changes to the core is needed, you
> can always push to a separate branch in the meantime. Anyway, I’m
> confident!

Sounds good. Take care, Ludo!

Regards,
Jakob
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 5 years and 272 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.