[Haskell-cafe] FRP: how does integration work?

martin martin.drautzburg at web.de
Sat Jan 20 14:09:52 UTC 2018

Hello all,

I am at best half-educated when it comes to FRP, so feel free to direct me to the homework I should do before asking
obvious questions.

I vaguely remember Paul Hudak talking about integrating a Signal (aka Behavior). Now I have this image in my head, where
a Behavior is like vector graphics, except its domain Time and not space. Also I heard the term "late sampling" in
conjunction with FRP. Bot ideas make sense to me.

So if I look at integration in vector graphics, I might want to get the area between a curve and the x-axis.

If I render the curve and then count the pixels between the curve and x-axis, the result will depend on the resolution.
With a very low resolution, I'll get a crude approximation of the true area and as I increase the resolution I'll get
better approximations and with infinite resolution I'll get the true area. So the result of integration seems to depend
on the chosen resolution.

Conversely, with pixel graphics, the resolution is fixed right from the start and I cannot not up the resolution at all,
at best I could downsample.

In FRP I should have something like:

	newtype Behavior a = Behavior (Time -> a)
	type Curve = Behavior Double
	integral :: Curve -> Double -> Curve -- 2nd parameter is the integration constant

But what do I get when I take the value of the integral at a given point in time?

	integralAt :: Time -> Curve -> Double
	integralAt t curve = let (Behaviour i) = integral curve 0
			     in	i t

Nowhere do I mention any (temporal) resolution. How does the integral function know which resoltion to choose?

More information about the Haskell-Cafe mailing list