[Haskell-cafe] Sample rate inference

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Thu Nov 11 11:18:01 EST 2004

Koji Nakahara <yu- at div.club.ne.jp> wrote:

> On Thu, 11 Nov 2004 10:49:13 +0100 (MEZ)
> Henning Thielemann <iakd0 at clusterf.urz.uni-halle.de> wrote:
> >  The computation sample rate should be propagated through the network as
> > follows:
> >   If in a component of equal sample rate some processors have the same
> > fixed sample rate, all uncertain processors must adapt that. 
> >   If some processors have different fixed sample rates this is an error. 
> >   If no processor has a fixed sample rate, the user must provide one
> > manually.
> >  To me this looks very similar to type inference. Is there some mechanism
> > in Haskell which supports this programming structure? 
> This may not what you are looking for,
> but I would simply use Reader Monad or like.

Or you could make use of laziness in the following way:

- have every processor give its preferred rate as an output, and take the chosen rate as input.
- have the combinator examine all the outputs, choose the rate (giving an error if this is not possible), and pass the chosen rate to all the processors' inputs.

This could be wrapped in a reader and a writer monad if desired, or some custom combinators could be constructed.

See http://www.haskell.org/hawiki/CircularProgramming for more examples of this pattern.

--KW 8-)

Keith Wansbrough <kw217 at cl.cam.ac.uk>
University of Cambridge Computer Laboratory.

More information about the Haskell-Cafe mailing list