[Haskell-cafe] Infinite lists in real world programs
Yves Parès
limestrael at gmail.com
Sat Dec 25 22:49:32 CET 2010
Hello,
I keep on experimenting with Elerea. I'm on my way to achieve a simple Pong
game, but the display is awfully jerky, however the sampling occurs on
average every 0,0015 sec, which gives 670 FPS.
All the elerea-examples run perfectly fine on my computer, however I use
FRP.Elerea.Param, which none of the examples use. But there isn't no known
problem with Param?
(Even if it's much more likely it comes from my code...)
2010/12/23 Yves Parès <limestrael at gmail.com>
> Thanks for your answers. In fact I tried to use Simple with a clock signal
> and it's painful to pass it wherever you need it. Param is much more
> practical.
> I like Elerea, I tried Reactive and Yampa, and I found them (especially
> Yampa) heavy and not very practical.
> The fact that Elerea is minimalistic makes it easier to learn/use and more
> flexible.
>
> 2010/12/23 Patai Gergely <patai_gergely at fastmail.fm>
>
> > fromList :: [a] -> SignalGen (Signal a)
>> > fromList xs =
>> > stateful xs tail >>= memo . fmap head
>> >
>> > 1) It does what I want, but is it the good way to do it?
>> Yes, I'd do it the same way, assuming that the input is always an
>> infinite list (so this version should probably be called
>> unsafeFromList...). But you can always make a list infinite, just add a
>> Maybe layer or pad with a default value.
>>
>> > 2) Since the returned signal may be used in several places and since I
>> > obtain it through the generic fmap (and not through an Elerea
>> primitive),
>> > I guessed I had to "memo" it instead of simply using "return". Did I
>> guess
>> > right?
>> That's exactly what memo is needed for, yes. However, whether it is
>> worth the overhead in such a simple case (after all, head is essentially
>> just a single dereferencing step) should be determined by profiling.
>>
>> > 3) Concerning the functionnality added by the Param implementation, I
>> > have
>> > the impression that the same can be achieved through the use of an
>> > external
>> > signal in Simple (*). Am I right?
>> Yes, the two are equally expressive. The difference is the way you
>> access the signals. In the case of Param, you get a globally accessible
>> signal that you don't need to pass around explicitly, just retrieve with
>> 'input' wherever you want. This might be useful when there's some
>> ubiquitous piece of information that you need practically everywhere,
>> e.g. real time for a simulation.
>>
>> Gergely
>>
>> --
>> http://www.fastmail.fm - Does exactly what it says on the tin
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101225/7378836b/attachment.htm>
More information about the Haskell-Cafe
mailing list