GNU bug report logs - #30237
Generalizing ‘and=>’

Previous Next

Package: guile;

Reported by: Mathieu Lirzin <mthl <at> gnu.org>

Date: Wed, 24 Jan 2018 12:11:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Mathieu Lirzin <mthl <at> gnu.org>
To: 30237 <at> debbugs.gnu.org
Subject: bug#30237: Generalizing ‘and=>’
Date: Wed, 24 Jan 2018 13:10:20 +0100
Hello,

Here is a proposal for generalizing ‘and=>’ to a pipeline of procedures.
It acts like a “bind” operator in an ad-hoc “Maybe” monad which uses #f
to represent the absence of value.  Not sure if it is useful in
practice, but it feels like a natural generalization.

The current definition is the following:

  (define (and=> value procedure)
    (and value (procedure value)))

Here is my proposition:

  (define-syntax and=>
    (syntax-rules ()
      ((_) #t)
      ((_ val) val)
      ((_ val proc)
       (and val (proc val)))
      ((_ val proc proc* ...)
       (and=> (and val (proc val)) proc* ...))))

Let me know if such change is welcome or not, so I can provide a
complete patch including documentation.  Even if it's a small change, I
would like to assign copyright for future changes.

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37




This bug report was last modified 4 years and 26 days ago.

Previous Next


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