Thanks for answering, Alex. I do already understand the limitations of 
halt-when from the implementation point of view.

To make my question more clear: What kind of practical problem is halt-when 
designed to solve, especially as a very limited transducer?

I am failing derive any practical problem from your examples and similar 
ones I have made up for myself - Inputs / transducers producing custom 
error objects that one wants to return don't really seem like something one 
encounters when writing Clojure, do they?

Kind regards,
 Leon.

On Thursday, November 3, 2016 at 8:03:16 PM UTC+1, Alex Miller wrote:
>
> halt-when does require some knowledge about the transducible context where 
> it is used, particularly because it will be exposed to the completed result 
> of the computation. I think it's really primarily applicable for something 
> like transduce (and not as much for into, sequence, eduction, or chan for 
> differing reasons).
>
> (transduce (comp (halt-when :err) (map inc)) + 0
>
>   (range 5))
>
> ;;=> 15
>
>
> (transduce (comp (halt-when :err) (map inc)) + 0
>
>    (concat (range 3) [{:err "oops"}] (range 3)))
>
> ;;=> {:err "oops"}
>
>
>
>
>
> On Thursday, November 3, 2016 at 1:06:36 PM UTC-5, Leon Grapenthin wrote:
>>
>> What is the intended usage of halt-when? 
>>
>> The naming of halt-when hints at imperative / non-collection contexts but 
>> I'm failing to guess what such a context could look like? 
>>
>> What is an intended usecase for the default behavior "the input that 
>> triggered the predicate will be returned"? 
>>
>> For collection contexts, it seems odd that the transduced result is not 
>> opaque to retf because it requires one to make the transducer depend on the 
>> later application which breaks promise/design of transducers as reusable 
>> algorithmic transformations in many contexts.
>>
>> To illustrate
>>
>> (into [] (halt-when true? conj) [false false true])
>>
>> Doesn't work because into internally uses transients. One has to 
>> (halt-when true? conj!), then [false false true] is returned - but it is a 
>> hack using the internals of into.
>>
>> (sequence (halt-when true? conj) [false false true])
>>
>> Returns (false false), a different result.
>>
>> For core.async channels I can imagine that it doesn't work at all, but 
>> have not tried.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to