[Fieldtrip] Re: [reactive] Transforming Behaviors

2 views
Skip to first unread message

Conal Elliott

unread,
Nov 24, 2008, 2:23:12 PM11/24/08
to Greg Fitzgerald, Fiel...@haskell.org, reac...@haskell.org
The instances would get added to the reactive-fieldtrip package.  That package is currently very small, but I anticipate lots of goodies going in that relate to the combined use of Reactive and FieldTrip.

On Mon, Nov 24, 2008 at 11:18 AM, Conal Elliott <co...@conal.net> wrote:
Hi Greg,

I don't think anyone has implemented an instance for static transformations of dynamic geometry.  Ought to be easy, though.  Also dynamic transformation of static geometry and dynamic transformation of dynamic geometry.  And the corresponding three additional instances for 2D geometry.  All six would be very useful.

So I don't forget, would you please submit a ticket to either http://trac.haskell.org/reactive or http://trac.haskell.org/FieldTrip ?

You might also enjoy adding these instances yourself.  Patches are very welcome.

Thanks,  - Conal


On Mon, Nov 24, 2008 at 10:27 AM, Greg Fitzgerald <gar...@gmail.com> wrote:
Should it be possible to write this:

spinningTorusPair :: Double -> Behavior Geometry3
spinningTorusPair sz = uscale3 sz *% spinningG torusPair

Instead of this:

spinningTorusPair :: Double -> Behavior Geometry3
spinningTorusPair sz = (uscale3 sz *%) <$> spinningG torusPair


That is, should a Behavior of something transformable be an instance
of Transform as well?  Has anyone tried to implement this instance?

Thanks,
Greg
_______________________________________________
Reactive mailing list
Reac...@haskell.org
http://www.haskell.org/mailman/listinfo/reactive


Greg Fitzgerald

unread,
Nov 24, 2008, 6:56:02 PM11/24/08
to Conal Elliott, Fiel...@haskell.org, reac...@haskell.org
>> static transformations of dynamic geometry.
>> dynamic transformation of static geometry and dynamic transformation of
>> dynamic geometry. And the corresponding three additional instances for 2D
>> geometry. All six would be very useful.

Implementing just the dynamic transformation of dynamic geometry seems
to work out best.

instance Transform xf a => Transform (Behavior xf) (Behavior a) where
(*%) = liftA2 (*%)

With the other instances, GHC complains about ambiguities, and it's
easy enough to pull either side up into the dynamic realm.

Thanks,
Greg
_______________________________________________
FieldTrip mailing list
Fiel...@haskell.org
http://www.haskell.org/mailman/listinfo/fieldtrip

Conal Elliott

unread,
Nov 24, 2008, 9:34:48 PM11/24/08
to Greg Fitzgerald, Fiel...@haskell.org, reac...@haskell.org
Ah, I didn't foresee those ambiguities, but now I see what you mean.  I've added your instance below (exactly how this sort of thing comes out for me as well), used in Test.hs, and pushed & released reactive-fieldtrip-0.0.4.  And yeah, adding a 'pure' to promote static to dynamic is pretty easy.

Note that now Test.hs imports FRP.Reactive.FieldTrip (a new collect/re-export module) instead of FRP.Reactive.FieldTrip.Adapter.

Thanks for the suggestion, Greg.

  - Conal

Greg Fitzgerald

unread,
Nov 25, 2008, 1:10:48 PM11/25/08
to Conal Elliott, reac...@haskell.org, Fiel...@haskell.org
> I've added your instance below (exactly how this sort of thing comes out for me
> as well), used in Test.hs, and pushed & released reactive-fieldtrip-0.0.4.

Cool, I updated my Bounce example to reactive-fieldtrip-0.0.4. It now
bounces pairs of spinning torus pairs on left mouse clicks. Comments
welcome.

http://hpaste.org/12365

-Greg

Conal Elliott

unread,
Nov 25, 2008, 1:57:27 PM11/25/08
to Greg Fitzgerald, Fiel...@haskell.org, reac...@haskell.org
Wow.  What fun, Greg!!  I really love this simple example.

I annotated your post with a tweaked version, to make the rotations different and have opposite directions.

I can see there's a performance problem somewhere in reactive that's causing the animation to slow down with more button clicks.  Even worse, under ghci, additional runs are slow from the start.  I guess that means there are still some running threads.  Clearly some work to be done in the implementation.

 - Cona
Reply all
Reply to author
Forward
0 new messages