I'm trying to get to grips with Yampa, but from the definition of the higher-level signal functions like integral
it's not obvious to me how I would define such signal functions myself with Yampa's exported combinators with idiomatic Haskell (I don't care about performance at the moment). My goal is to learn how I can write my own combinators for debouncing, buffering, grouping, etc.
The integral
function is defined with the unexported constructors SF
and SF'
. How can I write it only with the other exported combinators, possibly using a more idiomatic Yampa style with switches and arrow notation?
integral :: VectorSpace a s => SF a a
integral = SF {sfTF = tf0}
where
tf0 a0 = (integralAux igrl0 a0, igrl0)
igrl0 = zeroVector
integralAux igrl a_prev = SF' tf -- True
where
tf dt a = (integralAux igrl' a, igrl')
where
igrl' = igrl ^+^ realToFrac dt *^ a_prev