Re: Named procedure; RE: SRFI 197: Threading Macros
Marc Nieper-Wißkirchen 09 Jun 2020 15:58 UTC
Am Di., 9. Juni 2020 um 17:47 Uhr schrieb Arne Babenhauserheide
<xxxxxx@web.de>:
> maybe chaining?
Chaining is nice because it reminds one of the chaining rule in
calculus, which is about the composition of functions.
However, `->' does not only compose functions, it also applies the
composition to some initial argument. So it is really the monadic
bind, not just a compose/chain operation.
(bind x f g h)
doesn't look too bad, does it?
In the general monadic framework that is taking shape, it would be
defined (yet to be extended to multiple values) just by
(define (bind x . f*)
(fold (lambda (f x) (f x)) x f*))
The syntactic sugar can be provided by SRFI 26 as in:
(bind x (cut f 1 <>) (cut g <> 2))
This makes it pretty obvious and explicit (and, I would say, in the
tradition of Scheme) how the parameter is threaded through.