Dear community,
I've been working with functions for a while that require multiple inputs in the DSignal dom n context and produce results with DSignal dom (n+d) context. In cases where I want to apply these functions to arguments with a different amount of accumulated delay
(e.g DSignal dom 0 and DSignal dom 3), I have to explicitly delay the argument with the lower amount of delay such that both delays are the same. I'm trying to find a way to automatically match the amount of delays without introducing unnecessary delays.
Consider the following toy example:
multiply :: (Num a, HiddenClockResetEnable dom, NFDataX a) => DSignal dom n a -> DSignal dom n a -> DSignal dom (n + 3) a
multiply a b = delayN d3 0 ((*) <$> a <*> b)
I'm trying to find a way to delay a or b based on which has a lower delay. I found that delaying both input arguments with delayedI causes problems where Clash can not properly derive the amount of delay.
Is there a way to do this in a clean way? Perhaps by creating a constraint that forces d1 or d2 to be 0 in the following type example?
multiply :: (Num a, HiddenClockResetEnable dom, NFDataX a, (n1+d1) ~ (n2+d2)) => DSignal dom (n1 + d1) a -> DSignal dom (n2 + d2) a -> DSignal dom ((n2 + d2) + 3) a
Kind regards,
Lucas