Re: First thoughts Wolfgang Corcoran-Mathe 01 Apr 2020 13:56 UTC

On 2020-03-30 19:12 +0200, Marc Nieper-Wißkirchen wrote:
>How the values are stored inside the Maybe is a question internal to the
>The generalization I am proposing means that `just' takes an arbitrary
>number of values and that `maybe-ref' may an arbitrary number of values to
>`success'. `proc's and `mproc's may take more than one value and may return
>more than one value.

Some thoughts about multiple values in SRFI 189:

* Would ‘maybe-ref/default’ require as many “default” arguments as
  values contained in the “maybe” argument, or would it always return
  a single default value in the Nothing case?  The former is sort of
  reasonable assuming we could access the number of values stored in
  a Just.

* How should multiple-value-storing Justs be compared with ‘maybe=’?
  Presumably Justs j1 and j2 are equal in the sense of maybe= iff
  j1 and j2 both return the same number of values and their values
  are element-wise equal (in the sense of the comparison procedure
  passed to maybe=).  Are there other complexities to be considered

* How can ‘maybe-join’ handle Justs with multiple Just payloads?
  e.g. would (maybe-join (just (just 1) (just 2))) return a value
  equivalent to (just 1 2), or something else?

* Should ‘maybe-contains?’, ‘maybe-filter’, and ‘maybe-remove’
  traverse the values of a multiple-value Just?  That is, could we
  expect results like the following:

  (maybe-contains? eqv? (just 'a 'b) 'b)  ; => #t

  (maybe-filter boolean? (just 'a #t))    ; => (just 'a)

  If these semantics were adopted, would it be consistent for
  ‘maybe-length’ to give the number of values contained in a Just?

* Would Either also allow multiple values?  (Presumably.)

It seems that it would be necessary for a Just to store the number
of values it contains along with the values themselves.  We could
expose the number of values contained in a Just, e.g. with

All in all, this is interesting, but seems to me to be a substantial
increase in complexity.  The possible semantics of some of these
procedures (especially ‘maybe=’ and the sequence operations) in the
presence of multiple-value Justs all seem pretty awkward.  It’s quite
possible that I’ve missed a better approach, though.


Wolfgang Corcoran-Mathe  <>

"Conquering the galaxy is what bacteria with spaceships would
do--knowing no better, having no choice." --Greg Egan, _Disapora_