Shouldn't Reactive also have VectorSpace instances for Behaviors of VectorSpace elements? So that the code becomes<div><div><br><div>> positionB x0 v t = pure x0 ^+^ v ^* t</div><div><br></div><div>Maybe it already has, in that case, sorry for the spam ;)<br>
</div><div><br></div><div><div class="gmail_quote">On Fri, Nov 21, 2008 at 7:00 PM, Greg Fitzgerald <span dir="ltr"><<a href="mailto:garious@gmail.com">garious@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">>>> positionB :: Double -> Behavior Double -> Behavior Double -> Behavior Double<br>
>>> positionB x0 v t = (x0 +) <$> liftA2 (*) v t<br>
</div><div class="Ih2E3d">> positionB x0 v t = pure x0 + v * t<br>
<br>
</div>That's very convenient. I'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 class="Wj3C7c"><br>
<br>
On Fri, Nov 21, 2008 at 6:48 AM, Conal Elliott <<a href="mailto:conal@conal.net">conal@conal.net</a>> wrote:<br>
> For that matter, you can also say, thanks to Num overloading:<br>
><br>
> positionB :: Double -> Behavior Double -> Behavior Double -> Behavior Double<br>
> positionB x0 v t = pure x0 + v * t<br>
><br>
> Sadly, similar convenience does not come for free with non-methods, such as<br>
> most of the FieldTrip API. For non-methods, in the past (with Fran), I've<br>
> written parallel sets of modules with behavior-lifted functionality. It's<br>
> tedious to set up but convenient to use. Perhaps a tool could automate the<br>
> job.<br>
><br>
> By the way, a nice feature of Yampa is that it avoids this lifting business<br>
> altogether, via desugaring for the arrow notation.<br>
><br>
> - Conal<br>
><br>
> On Fri, Nov 21, 2008 at 12:14 AM, Thomas Davie <<a href="mailto:tom.davie@gmail.com">tom.davie@gmail.com</a>> wrote:<br>
>>><br>
>>> positionB :: Double -> Behavior Double -> Behavior Double -> Behavior<br>
>>> Double<br>
>>> positionB x0 v t = (x0 +) <$> liftA2 (*) v t<br>
>><br>
>> On an unrelated note, I created a package called InfixApplicative, because<br>
>> I found that exactly this kind of expression looked ugly in my code. If you<br>
>> import it, you can define this instead:<br>
>><br>
>> positionB x0 v t = (x0 +) <$> (v <^(*)^> t)<br>
>><br>
>> Hope that helps<br>
>><br>
>> Bob<br>
>> _______________________________________________<br>
>> Reactive mailing list<br>
>> <a href="mailto:Reactive@haskell.org">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>
><br>
><br>
_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org">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>