
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
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
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@haskell.org http://www.haskell.org/mailman/listinfo/reactive