From: Mathieu Lirzin <mthl@gnu.org>
To: 30237@debbugs.gnu.org
Subject: bug#30237: Generalizing ‘and=>’
Date: Wed, 24 Jan 2018 13:10:20 +0100 [thread overview]
Message-ID: <877es731ar.fsf@gnu.org> (raw)
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
next reply other threads:[~2018-01-24 12:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 12:10 Mathieu Lirzin [this message]
2018-01-24 15:01 ` bug#30237: Generalizing ‘and=>’ Mark H Weaver
2018-01-24 20:08 ` Mathieu Lirzin
2018-01-31 4:31 ` Mark H Weaver
2018-01-31 14:23 ` Mathieu Lirzin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877es731ar.fsf@gnu.org \
--to=mthl@gnu.org \
--cc=30237@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).