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

2011-10-20 Thread Captain Freako
Hi David, I was referring to the `f' in the `runAuto' function, not the `liftAu' function. -db On Wed, Oct 19, 2011 at 8:53 PM, David Barbour dmbarb...@gmail.com wrote: On Wed, Oct 19, 2011 at 8:07 PM, Captain Freako capn.fre...@gmail.com wrote: One more question on the `runAuto' code,

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

2011-10-20 Thread David Barbour
On Thu, Oct 20, 2011 at 5:19 AM, Captain Freako capn.fre...@gmail.comwrote: Hi David, I was referring to the `f' in the `runAuto' function, not the `liftAu' function. -db Ah, I see. You quoted one thing and spoke of another, and I got all confused. Keep in mind that functions are arrows

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

2011-10-20 Thread John Lask
On 21/10/2011 3:00 AM, David Barbour wrote: the f in (Automaton f) is a pure funtion runAuto is deconstructing the arrow by pattern matching then applying the function to the input to obtain the result and the continuation. i.e. runAuto takes an arrow and applies it to a value. On Thu, Oct

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

2011-10-19 Thread Captain Freako
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

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

2011-10-19 Thread John Lask
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'

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

2011-10-19 Thread Captain Freako
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

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

2011-10-19 Thread Captain Freako
One more question on the `runAuto' code, John: If I understand the code correctly, `f' is an arrow. Yet, we're using it on the right side of `=' in a simple assignment. How are we getting away with that? Thanks, -db On Wed, Oct 19, 2011 at 3:02 PM, John Lask jvl...@hotmail.com wrote: On

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

2011-10-19 Thread David Barbour
On Wed, Oct 19, 2011 at 8:07 PM, Captain Freako capn.fre...@gmail.comwrote: One more question on the `runAuto' code, John: If I understand the code correctly, `f' is an arrow. Yet, we're using it on the right side of `=' in a simple assignment. How are we getting away with that? Thanks,

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

2011-10-18 Thread Captain Freako
Hi John, Thanks for this reply: Date: Tue, 18 Oct 2011 14:05:22 +1030 From: John Lask jvl...@hotmail.com Subject: Re: [Haskell-cafe] How to implement a digital filter, using Arrows? To: haskell-cafe@haskell.org Message-ID: BLU0- smtp384394452fd2750fbe3bcfcc6...@phx.gbl Content-Type

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

2011-10-18 Thread Ryan Ingram
. Which I think is what you want anyways! -- ryan On Tue, Oct 18, 2011 at 2:35 PM, Captain Freako capn.fre...@gmail.comwrote: Hi John, Thanks for this reply: Date: Tue, 18 Oct 2011 14:05:22 +1030 From: John Lask jvl...@hotmail.com Subject: Re: [Haskell-cafe] How to implement a digital

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

2011-10-18 Thread John Lask
{-# LANGUAGE Arrows #-} This is literate code. It expounds on your initial question and provides two solutions based either on the StateArrow or Automaton module Test where import Data.List ( mapAccumL ) import Control.Arrow import Control.Arrow.Operations import

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

2011-10-17 Thread Captain Freako
Hi all, If I have a pure function, which maps `(input, initialState)' to `(output, nextState)', what's the most succinct way of constructing a digital filter from this function, using Arrows? Thanks, -db ___ Haskell-Cafe mailing list

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

2011-10-17 Thread John Lask
your function corresponds with Control.Arrow.Transformer.Automaton. If you frame your function is such most of your plumbing is taken care of. http://hackage.haskell.org/packages/archive/arrows/0.4.1.2/doc/html/Control-Arrow-Transformer-Automaton.html On 18/10/2011 1:46 PM, Captain Freako