into not compatible with halt-when transducer

Description

It is common to process a collection of results with a transducer stack. When the results contain an anomaly, it would be nice for halt-when to be able to terminate processing and return the failing result or barge another value through. This is possible with a bespoke transduce+conj, but not with into:

halt-when always gets passed a (completed) result from the outer process, so the retf always needs to be somewhat aware of what that outer process is, but the implementation of `into` doesn't pass any useful completing function to the transduce, instead completing on the 'outside':

where COMPLETE == persistent! + reattach metadata

That means that halt-when sees a transient + failing input, instead of a persistent + failing input. Which means that you're going to get a ClassCastEx inevitably.

If halt-when received a persistent data structure instead of a transient, it would enable this reasonable use case:

https://gist.github.com/ghadishayban/a24a3b2f77d2b5ae53a43d7f114555ba

Environment

None

Assignee

Unassigned

Reporter

Ghadi Shayban

Labels

None

Approval

None

Patch

None

Affects versions

Priority

Major
Configure