[Haskell-cafe] How to implement a digital filter, using Arrows?

Captain Freako capn.freako at gmail.com
Thu Oct 20 04:39:45 CEST 2011


Thanks, John. I think I understand what you've done, below.
However, it's made me realize that I don't understand something about
your original code:

When the `liftAu' function was only returning `y', how were we able to
get `(y, a)' out of it, when we called it from `runAuto'?

Thanks,
-db


On Wed, Oct 19, 2011 at 3:02 PM, John Lask <jvlask at hotmail.com> wrote:
> On 20/10/2011 5:11 AM, Captain Freako wrote:
>
> for your use case then, the StateArrow seems more appropriate as it provides
> you with the final state. Ofcourse the Automaton arrow could also be used:
>
>> liftAu' f s0 = proc x -> do
>>    rec (y,s') <- arr f -< (x,s)
>>        s <- delay s0 -< s'
>>    returnA -< (y,s)
>
> this explicitly returns the state with evry value. However, you then need to
> manually thread the state through.
>
> note: the arrow "plumbing" is only used when you start composing filters,
> with arrow combinators. If your not doing any composition as
> such then lifting your functions into the "arrows" is not buying you much.
>
>> John Lask wrote:
>>
>>> This is literate code. It expounds on your initial question and provides
>>> two solutions based either on the StateArrow or Automaton....
>>> (Remainder omitted.)
>>
>> John,
>>
>> Thanks so much for your help!
>> I'm going to study your example code and try to understand how the
>> Automaton implicit plumbing is being used.
>> (I'm determined to get my head around this arrow concept, damn it! ;-) )
>>
>> I wonder if I might pester you for the final piece of the puzzle here:
>> When the processing of the input stream through the filter is
>> complete, I need to pass the final filter state, along with the output
>> stream, back to the calling program.
>> (This is because the calling program is going to split the input
>> signal into conveniently sized chunks, calling my filter routine
>> several times, in order to process the entire input stream. It expects
>> to be able to pass an initial filter state into my routine, which is
>> just the final state of the filter that I passed back to it after the
>> previous call. In this way, we avoid inserting any edge artifacts at
>> the input stream segmentation boundaries.)
>>
>> So, is it possible to `fetch' the final state out of that Automaton,
>> when it's finished processing the input list?
>>
>> Thanks!
>> -db
>>
>>
>
>



More information about the Haskell-Cafe mailing list