Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-26 Thread Patai Gergely
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. I had a similar experience under Windows. Never really got to find out why it happened. You might

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-26 Thread Yves Parès
I had a similar experience under Windows. Never really got to find out why it happened. You might try adding a short threadDelay call in your main loop and see what happens; I think it helped back then. Wow... it's even worse. Even with a threadDelay of 1ms the FPS drop down to a chaotic 20~30. I

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-26 Thread Patai Gergely
I forgot to say: I run Ubuntu 10.10 (32bits), and I use HGL for the graphics, not GLFW. This may be important since HGL seems to react badly to threadDelay Oh, HGL! The Yampa Arcade example (SpaceInvaders) suffered from the same problem, and it was solved by adding the -threaded switch. Without

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-25 Thread Yves Parès
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

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-23 Thread Patai Gergely
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...).

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-23 Thread Yves Parès
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

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-22 Thread Yves Parès
Patai, I read your paper on Elerea. It wasn't easy :), but I think I got the picture. So I would have 2 questions : I made a simple function which turns an infinite list into a signal : fromList :: [a] - SignalGen (Signal a) fromList xs = stateful xs tail = memo . fmap head 1) It does what I

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-18 Thread Yves Parès
Thanks you all for your links, I will read this. However, Brent, I fail to understand your implementation of Monad... I understand the purpose, but not the algorithm. 2010/12/18 Matthew Sottile mjsott...@mac.com Hi- This may be of some interest:

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-16 Thread Yves Parès
Okay, I started to experiment things, and I came to some remarks: First, I cannot use bare lists, because of the way their Applicative instance is declared. I have to use the newtype ZipList (in Control.Applicative). So I have roughly this : import Control.Applicative newtype AgentSig a =

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-16 Thread Brent Yorgey
On Thu, Dec 16, 2010 at 06:52:58PM +0100, Yves Parès wrote: Okay, I started to experiment things, and I came to some remarks: First, I cannot use bare lists, because of the way their Applicative instance is declared. I have to use the newtype ZipList (in Control.Applicative). So I have

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-16 Thread Patai Gergely
So in the result of (a = f), the first element is taken from the first element of applying f to the first element of a; the second element is the second element in the result of applying f to the second element of a; and so on. Off the top of my head I am not sure what this corresponds to in

[Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Yves Parès
Hello Café, I was wondering if using infinite lists was a viable and efficient solution in haskell programs (I mean not simple prototypes) : I was considering using them to model agents in a hierarchical multi-agent application for school. A list would representate the state of an agent at a step

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Brent Yorgey
On Wed, Dec 15, 2010 at 02:52:11PM +0100, Yves Parès wrote: Hello Café, So is it viable or would the use of multiple infinite lists kill the performances? Sounds perfectly reasonable to me. I don't see any reason why using multiple infinite lists would have anything to do with the

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Yves Parès
try to compute their length Yes ^^, that's silly. I don't see any reason why using multiple infinite lists would have anything to do with the performance That's comforting. Well, it seems to be a very simple, haskellish and elegant solution, so basic pragmatism -- with an slice of pessimism

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Edward Z. Yang
It sounds like a good fit for your problem as stated. One thing to note is that Haskell will give you great abstractions for very strong amounts of code, as long as what you want to do is a good fit for the abstraction. Haskell makes it quite hard to fit a square peg into a round hole, so if one

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Yves Parès
if one day you decide you need an agent that generates random numbers I could say that my agents now run in a certain monad, I just would have to transform my basic agents to : agent1 = liftM . fmap (*2) (or even agen1 = fmap . fmap (*2), however it is less readable IMO) Thanks for your

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Brent Yorgey
On Wed, Dec 15, 2010 at 06:38:04PM +0100, Yves Parès wrote: try to compute their length Yes ^^, that's silly. I don't see any reason why using multiple infinite lists would have anything to do with the performance That's comforting. Well, it seems to be a very simple, haskellish and

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-15 Thread Edward Z. Yang
Excerpts from Yves Parès's message of Wed Dec 15 13:28:11 -0500 2010: if one day you decide you need an agent that generates random numbers I could say that my agents now run in a certain monad, I just would have to transform my basic agents to : agent1 = liftM . fmap (*2) (or even agen1