Upcoming changes to the SRFI Hernán Ibarra Mejia (05 Sep 2026 22:48 UTC)
Re: Upcoming changes to the SRFI Peter McGoron (06 Sep 2026 02:32 UTC)
Re: Upcoming changes to the SRFI Hernán Ibarra Mejia (06 Sep 2026 11:00 UTC)

Upcoming changes to the SRFI Hernán Ibarra Mejia 05 Sep 2026 22:48 UTC

Dear all,

Thank you for the generous feedback. I have read all of it, though I still need
to reply to a couple of people.

Since many (all?) find the */m API confusing, I have landed in what I think is a
significant improvement: monadic-let, monadic-begin, et al. I also changed my
mind in regards to minimality, and will add some quality of life procedures. To
accomodate these, I will reorganize the library into submodules.

These are the tentative exports of (srfi 280 base):

    [parameter] default-monad

    [procedure] (make-monad unit bind-proc)
    [procedure] (monad? obj)

    [procedure] (return obj [monad])
    [procedure] (bind $ proc [monad])
    [procedure] (join $$ [monad])
    [procedure] (lift proc [monad])

    [syntax] (monadic-begin <expression> ...)
    [syntax] (monadic-apply <procedure> <arg> ... <args>)
    [syntax] (monadic-let <bindings> <body>)
    [syntax] (monadic-let* <bindings> <body>)

    [syntax] (explicit-monadic-begin <monad> <expression> ...)
    [syntax] (explicit-monadic-apply <monad> <procedure> <arg> ... <args>)
    [syntax] (explicit-monadic-let <monad> <bindings> <body>)
    [syntax] (explicit-monadic-let* <monad> <bindings> <body>)

I won't explain everything in detail now, but here are a few remarks:

- default-monad is a R7RS parameter. When the [monad] argument is missing in
  return, bind, join, and lift, (default-monad) is assumed.

- What before was (do/m (default-monad) foo bar baz) is now
  (monadic-begin foo bar baz).

- What before was

      (do/m (default-monad)
        (define/m x foo)
        (define/m y bar)
        (baz x y)
        (return/m buz))

  is now

      (monadic-let ((x foo) (y bar))
        (baz x y)
        (return buz))

- Roughly, the explicit-* variants parameterize the default-monad to <monad>
  before calling the non-explicit variants (not exactly but it's close).

I will also add some specific monads to the library. They will appear in the
following libraries:

    (srfi 280 identity-monad)
    (srfi 280 reader-monad)
    (srfi 280 writer-monad)
    (srfi 280 state-monad)
    (srfi 280 maybe-monad)
    ... etc.

Similary, I think it is worth adding monad transformers, though that may be too
ambitious.

    (srfi 280 transformers)
    (srfi 280 reader-transformer)
    (srfi 280 writer-transformer)
    (srfi 280 state-transformer)
    (srfi 280 maybe-transformer)
    ... etc.

I also plan to add a lot more examples, and incorporate the changes I agreed to
previously. Even though it's not what I originally envisioned, I will assume the
reader knows nothing about monads, and change my writing accordingly.

For those interested, you can check on my progress by visiting my personal git
repo for SRFI 280: <https://git.sr.ht/~nagbu/srfi-280> (patches welcome, of
course). A new draft will be released when substantial changes are completed, in
coordination with the editor.

Feel free to leave your thoughts on this rough plan.

Thanks again,
Hernán