[Haskell-cafe] Sample rate inference

Koji Nakahara yu- at div.club.ne.jp
Thu Nov 11 11:10:06 EST 2004

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.

newtype Rate = Rate Int
type Processor = Stream -> Reader Rate Stream

processor1 s = do rate <- ask; ...
processors = processor1 >>= processor2 >>= .. 

process = runReader (processors input) (Rate 44100)

Sorry for sending the same mail.  I didn't notice you set Reply to.
Koji Nakahara

More information about the Haskell-Cafe mailing list