Good point.&nbsp; There is already a VectorSpace instance for behaviors, and using it in the positionB definition makes for a much more general type.&nbsp; See FRP.Reactive.VectorSpace.<br><br>I wouldn&#39;t use v ^* t (or t *^ v), however, because v is dynamic.&nbsp; Integrating v ought to do the trick.<br>
<br>And I expect that any simple &amp; direct formulation will run into the current implementation bug with recursive behaviors, since the position depends on the velocity, the velocity depends on acceleration and accumulated impulse, and the accumulated impulse depends on position.<br>
<br>&nbsp; - Conal<br><br><div class="gmail_quote">On Fri, Nov 21, 2008 at 11:33 AM, Peter Verswyvelen <span dir="ltr">&lt;<a href="mailto:bugfact@gmail.com">bugfact@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Shouldn&#39;t Reactive also have VectorSpace instances for Behaviors of VectorSpace elements? So that the code becomes<div><div><div class="Ih2E3d"><br><div>&gt; positionB x0 v t = pure x0 &nbsp;^+^ &nbsp;v &nbsp;^* &nbsp;t</div><div><br></div>
</div><div>Maybe it already has, in that case, sorry for the spam ;)<br>
</div><div><div></div><div class="Wj3C7c"><div><br></div><div><div class="gmail_quote">On Fri, Nov 21, 2008 at 7:00 PM, Greg Fitzgerald <span dir="ltr">&lt;<a href="mailto:garious@gmail.com" target="_blank">garious@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>&gt;&gt;&gt; positionB :: Double -&gt; Behavior Double -&gt; Behavior Double -&gt; Behavior Double<br>
&gt;&gt;&gt; positionB x0 v t = (x0 +) &lt;$&gt; liftA2 (*) v t<br>
</div><div>&gt; positionB x0 v t = pure x0 + v * t<br>
<br>
</div>That&#39;s very convenient. &nbsp;I&#39;m showing this stuff off to visual<br>
designers, so tricks like this have great Sales appeal. :)<br>
<br>
If others are trying this out, the Num instance is implemented in<br>
FRP.Reactive.Num.<br>
<font color="#888888"><br>
-Greg<br>
</font><div><div></div><div><br>
<br>
On Fri, Nov 21, 2008 at 6:48 AM, Conal Elliott &lt;<a href="mailto:conal@conal.net" target="_blank">conal@conal.net</a>&gt; wrote:<br>
&gt; For that matter, you can also say, thanks to Num overloading:<br>
&gt;<br>
&gt; positionB :: Double -&gt; Behavior Double -&gt; Behavior Double -&gt; Behavior Double<br>
&gt; positionB x0 v t = pure x0 + v * t<br>
&gt;<br>
&gt; Sadly, similar convenience does not come for free with non-methods, such as<br>
&gt; most of the FieldTrip API. &nbsp;For non-methods, in the past (with Fran), I&#39;ve<br>
&gt; written parallel sets of modules with behavior-lifted functionality. &nbsp;It&#39;s<br>
&gt; tedious to set up but convenient to use. &nbsp;Perhaps a tool could automate the<br>
&gt; job.<br>
&gt;<br>
&gt; By the way, a nice feature of Yampa is that it avoids this lifting business<br>
&gt; altogether, via desugaring for the arrow notation.<br>
&gt;<br>
&gt; &nbsp; &nbsp;- Conal<br>
&gt;<br>
&gt; On Fri, Nov 21, 2008 at 12:14 AM, Thomas Davie &lt;<a href="mailto:tom.davie@gmail.com" target="_blank">tom.davie@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; positionB :: Double -&gt; Behavior Double -&gt; Behavior Double -&gt; Behavior<br>
&gt;&gt;&gt; Double<br>
&gt;&gt;&gt; positionB x0 v t = (x0 +) &lt;$&gt; liftA2 (*) v t<br>
&gt;&gt;<br>
&gt;&gt; On an unrelated note, I created a package called InfixApplicative, because<br>
&gt;&gt; I found that exactly this kind of expression looked ugly in my code. &nbsp;If you<br>
&gt;&gt; import it, you can define this instead:<br>
&gt;&gt;<br>
&gt;&gt; positionB x0 v t = (x0 +) &lt;$&gt; (v &lt;^(*)^&gt; t)<br>
&gt;&gt;<br>
&gt;&gt; Hope that helps<br>
&gt;&gt;<br>
&gt;&gt; Bob<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Reactive mailing list<br>
&gt;&gt; <a href="mailto:Reactive@haskell.org" target="_blank">Reactive@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/reactive" target="_blank">http://www.haskell.org/mailman/listinfo/reactive</a><br>
&gt;<br>
&gt;<br>
_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org" target="_blank">Reactive@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/reactive" target="_blank">http://www.haskell.org/mailman/listinfo/reactive</a><br>
</div></div></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br>