Suppose I have a *stateful* transducer

partitionBy : (List a -> Bool) -> Transducer a (List a) r (List a)
partitionBy pred =
    { init =
        \reduce r -> ( [], r )
    , step =
        \reduce input ( hold, r ) ->
            let
                merged =
                    input :: hold
            in
                if (pred merged) then
                    ( [], reduce merged r )
                else
                    ( merged, r )
    , complete =
        \reduce ( hold, r ) ->
            if (List.isEmpty hold) then
                r
            else
                reduce hold r
    }


that "chunkfies" an input stream input into lists, where the supplid 
predicate (List a -> Bool) determines when to start the next sublist.  (My 
particular toy application is the standard "Bowling Kata" in which I need 
to partition a stream of bowling throws into frames, but I think it could 
be generally useful.)

However, the "foldr" in the standard 

transduceList : Transducer a b (List b) s -> List a -> List b

transduceList =

    transduce List.foldr (::) []

means that the stateful processing occurs from the end, which is exactly 
the opposite from what I need. (Since I need my state to be dependent upon 
*earlier* messages, rather than *later* messages).


Am I making too much of this (i.e. should just use transduceArray and be 
done with it)?  Or is there something problematic about stateful 
transducers, in that different "folder" can result in different semantics?


Thanks!

Marshall


-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to