Typo in 'unfold' types Wolfgang Corcoran-Mathe (03 May 2026 19:58 UTC)
Re: Typo in 'unfold' types John Cowan (04 May 2026 00:01 UTC)

Typo in 'unfold' types Wolfgang Corcoran-Mathe 03 May 2026 19:58 UTC

Hello to the SRFI 1 list,

There are slight errors in the types given for 'unfold' and
'unfold-right'.  For 'unfold' the SRFI has:

    unfold p f g seed [tail-gen] -> list,

but this procedure will only return a proper list (which is what 'list'
means here) if the *tail-gen* procedure does, and the SRFI does not
require that.  Using the sample implementation you can easily build
improper lists with 'unfold', e.g.:

    (unfold (lambda (i) (= i 4))
            values
            (lambda (i) (+ i 1))
            1
            values)

      => (1 2 3 . 4).

If this is intended behavior, then the type should really be

    unfold p f g seed [tail-gen] -> object.

Similarly, 'unfold-right' should have the type

    unfold-right p f g seed [tail] -> object.

I think these are simply oversights, but it's possible Olin intended
at some point to restrict the 'tail-gen' and 'tail' arguments so that
the unfolds always return proper lists.  In any case, this restriction
doesn't appear in the final SRFI, so I'm lead to think that these types
are wrong.

--
Wolfgang Corcoran-Mathe  <xxxxxx@sigwinch.xyz>