[reactive] Bounce

Peter Verswyvelen bugfact at gmail.com
Fri Nov 21 14:33:53 EST 2008


Shouldn't Reactive also have VectorSpace instances for Behaviors of
VectorSpace elements? So that the code becomes
> positionB x0 v t = pure x0  ^+^  v  ^*  t

Maybe it already has, in that case, sorry for the spam ;)

On Fri, Nov 21, 2008 at 7:00 PM, Greg Fitzgerald <garious at gmail.com> wrote:

> >>> positionB :: Double -> Behavior Double -> Behavior Double -> Behavior
> Double
> >>> positionB x0 v t = (x0 +) <$> liftA2 (*) v t
> > positionB x0 v t = pure x0 + v * t
>
> That's very convenient.  I'm showing this stuff off to visual
> designers, so tricks like this have great Sales appeal. :)
>
> If others are trying this out, the Num instance is implemented in
> FRP.Reactive.Num.
>
> -Greg
>
>
> On Fri, Nov 21, 2008 at 6:48 AM, Conal Elliott <conal at conal.net> wrote:
> > For that matter, you can also say, thanks to Num overloading:
> >
> > positionB :: Double -> Behavior Double -> Behavior Double -> Behavior
> Double
> > positionB x0 v t = pure x0 + v * t
> >
> > Sadly, similar convenience does not come for free with non-methods, such
> as
> > most of the FieldTrip API.  For non-methods, in the past (with Fran),
> I've
> > written parallel sets of modules with behavior-lifted functionality.
>  It's
> > tedious to set up but convenient to use.  Perhaps a tool could automate
> the
> > job.
> >
> > By the way, a nice feature of Yampa is that it avoids this lifting
> business
> > altogether, via desugaring for the arrow notation.
> >
> >    - Conal
> >
> > On Fri, Nov 21, 2008 at 12:14 AM, Thomas Davie <tom.davie at gmail.com>
> wrote:
> >>>
> >>> positionB :: Double -> Behavior Double -> Behavior Double -> Behavior
> >>> Double
> >>> positionB x0 v t = (x0 +) <$> liftA2 (*) v t
> >>
> >> On an unrelated note, I created a package called InfixApplicative,
> because
> >> I found that exactly this kind of expression looked ugly in my code.  If
> you
> >> import it, you can define this instead:
> >>
> >> positionB x0 v t = (x0 +) <$> (v <^(*)^> t)
> >>
> >> Hope that helps
> >>
> >> Bob
> >> _______________________________________________
> >> Reactive mailing list
> >> Reactive at haskell.org
> >> http://www.haskell.org/mailman/listinfo/reactive
> >
> >
> _______________________________________________
> Reactive mailing list
> Reactive at haskell.org
> http://www.haskell.org/mailman/listinfo/reactive
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/reactive/attachments/20081121/0c84a5c7/attachment.htm


More information about the Reactive mailing list