[Haskell-cafe] [reactive] A pong and integrate
Peter Verswyvelen
bugfact at gmail.com
Sun May 16 16:12:12 EDT 2010
As far as I know, it was never possible to make a pong game in
Reactive, at least not with the versions I tried, but I admit a lot of
never versions got released since then. It would be great to see one
though :)
You might want to try Yampa, that works for sure (although you should
mark all your output data strict, as is done in the examples,
otherwise you might also get space leaks or shaky frame rates). Or
Elerea, which comes with a breakout game.
On Sun, May 16, 2010 at 9:30 PM, Limestraël <limestrael at gmail.com> wrote:
> Eventually, I don't think it is a profiling issue.
> Maybe a problem with integral. According to a quite recent post on the
> reactive mailing list, the following minimal code produces the same problem
> :
>
>> import FRP.Reactive
>
>> import FRP.Reactive.LegacyAdapters
>
>> import Control.Applicative
>
>> type Velocity = Double
>> type Position = Double
>
>> data Car = Car { vel :: Velocity, pos :: Position } deriving Show
>
>
>> velocity :: Behavior Velocity
>
>> velocity = 1
>
>> position :: Behavior Position
>> position = integral (atTimes [0, 0.5 ..]) velocity
>
>> car :: Behavior Car
>> car = Car <$> velocity <*> position
>
>
>
>> main :: IO ()
>> main = adaptE $ print <$> car `snapshot_` atTimes [0, 0.5..]
>
>> 1) why is the leak happen?
>> 2) how can I fix this problem?
>
>> Some more detailed informations:
>
>
>> * reactive 0.11.4
>> * GHC 6.12.1
>> * Gentoo Linux (2.6.32-tuxonice, x86_64) or Ubuntu 9.10 64bits
>> * compiled with or without -O2 flag
>
> 2010/5/16 David Leimbach <leimy2k at gmail.com>
>>
>>
>> On Sat, May 15, 2010 at 8:42 AM, Limestraël <limestrael at gmail.com> wrote:
>>>
>>> Okay,
>>> guess I'll have to bring out the chapter 25 of my Real World Haskell...
>>
>> I find it's often the most practical chapter that I hit a lot during
>> writes and changes to my server process I have in Haskell in our control
>> system code :-)
>> That plus the information that I had missed that Control.Monad.State
>> defaulted to the Lazy version (which is consistent, but for some reason it
>> got by me) helped me to realize why I was leaking so much space in a garbage
>> collected environment.
>> I wouldn't have gotten very far with Haskell as this piece of our code
>> without that chapter. I'd love to see more writing of that sort around
>> Haskell in book form. One can become fluent in tuning Haskell by trial and
>> error, but the sharp corners one must bump into are often sharper than in
>> other languages I've found.
>> Dave
>>
>>>
>>> 2010/5/15 Bulat Ziganshin <bulat.ziganshin at gmail.com>
>>>>
>>>> Hello Limestraėl,
>>>>
>>>> Saturday, May 15, 2010, 7:02:38 PM, you wrote:
>>>>
>>>> > But when I set my beat to tick every 60 times per second, the
>>>> > position is well updated, but I clearly see that the display
>>>> > dramatically slows down after a few seconds of execution. Too heavy
>>>> > rate for integrate?
>>>>
>>>> it may be due to lot of uncollected garbage that is result of lazy
>>>> evaluation. profile program to check its GC times
>>>>
>>>>
>>>> --
>>>> Best regards,
>>>> Bulat mailto:Bulat.Ziganshin at gmail.com
>>>>
>>>
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
More information about the Haskell-Cafe
mailing list