Hi Rohan,

I just ran into another instance of using an UGen with a Rate type that it does not support. I got the error:

   *** Exception: mk_osc: rate restricted: (KR,[AR],"Pulse")

but I thought this could also be solved on the type level.


data AudioRate = AudioRate
data ControlRate = ControlRate

class GenericRate rate where
   toRate :: rate -> Rate

instance GenericRate AudioRate where
   toRate AudioRate = AR

instance GenericRate ControlRate where
   toRate ControlRate = KR


impulse :: GenericRate rate => rate -> UGen -> UGen -> UGen

pulse :: AudioRate -> UGen -> UGen -> UGen


Even better would be to make the rate a type parameter of UGen:


impulse ::
   (GenericRate rateFreq, GenericRate rateWidth, GenericRate rate) =>
   UGen rateFreq -> UGen rateWidth -> UGen rate

pulse ::
   (GenericRate rateFreq, GenericRate rateWidth) =>
   UGen rateFreq -> UGen rateWidth -> UGen AudioRate

_______________________________________________
haskell-art mailing list
haskell-art@lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to