Re : [Haskell-cafe] Elerea/GLFW Tetris

2009-08-17 Thread jean legrand
As I've been warned, two dependencies (Common.Utils and Common.Vector) are to 
be resolved in order to use this Tetris code.
They're part of the elerea-examples package (from hackage) but their access is 
not public so a solution is to modify the cabal file during installation.

Another solution is to create a Common directory in the current directory, then 
decompress the source located in

http://hackage.haskell.org/package/elerea-examples

and copy the two files Vector.lhs and Utils.lhs in Common.


 Hi Haskellers,
 Here is my first real program in Haskell. 
 
 http://hpaste.org:80/fastcgi/hpaste.fcgi/view?id=8211
 
 In fact, I'm not fully responsible because it's just an
 adapted version of a Tetris Creighton Hogg had written for
 Reactive/GLUT. 
 As the first version, it's a very simple game (no levels,
 no points ...) but it's playable !
 
 The major problem is when the board is full, the program
 sadly stops for an empty list : indeed, I wasn't interested
 in that part and I prefered dealing with the signals.
 
 As the frame is the same as the breakout frame, it is also
 possible to launch the game with
 
 ./Tetris --dump-dot | dot -Tsvg -o tetris.svg
 
 in order to get an svg showing a graph of the signals. Any
 help is welcome to understand this graph !
 
 Every comment is welcome (especially about the first 170
 lines).
 Enjoy!




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re : [Haskell-cafe] Elerea/GLFW Tetris

2009-08-17 Thread Peter Verswyvelen
As a side-note, it might be interesting to use the Vec package on Hackage,
since it seems to offer fast, unboxed linear algebra.
On Mon, Aug 17, 2009 at 2:01 PM, jean legrand kkwwe...@yahoo.fr wrote:

 As I've been warned, two dependencies (Common.Utils and Common.Vector) are
 to be resolved in order to use this Tetris code.
 They're part of the elerea-examples package (from hackage) but their access
 is not public so a solution is to modify the cabal file during installation.

 Another solution is to create a Common directory in the current directory,
 then decompress the source located in

 http://hackage.haskell.org/package/elerea-examples

 and copy the two files Vector.lhs and Utils.lhs in Common.


  Hi Haskellers,
  Here is my first real program in Haskell.
 
  http://hpaste.org:80/fastcgi/hpaste.fcgi/view?id=8211
 
  In fact, I'm not fully responsible because it's just an
  adapted version of a Tetris Creighton Hogg had written for
  Reactive/GLUT.
  As the first version, it's a very simple game (no levels,
  no points ...) but it's playable !
 
  The major problem is when the board is full, the program
  sadly stops for an empty list : indeed, I wasn't interested
  in that part and I prefered dealing with the signals.
 
  As the frame is the same as the breakout frame, it is also
  possible to launch the game with
 
  ./Tetris --dump-dot | dot -Tsvg -o tetris.svg
 
  in order to get an svg showing a graph of the signals. Any
  help is welcome to understand this graph !
 
  Every comment is welcome (especially about the first 170
  lines).
  Enjoy!




 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re : [Haskell-cafe] Elerea/GLFW Tetris

2009-08-17 Thread jean legrand
 As I've been warned, two dependencies
 (Common.Utils and Common.Vector) are to be resolved in order
 to use this Tetris code.
 They're part of the elerea-examples package (from hackage)
 but their access is not public so a solution is to modify
 the cabal file during installation.
 
 Another solution is to create a Common directory in the
 current directory, then decompress the source located in
 
 http://hackage.haskell.org/package/elerea-examples
 
 and copy the two files Vector.lhs and Utils.lhs in Common.
 

but the simplest soltution is to get rid of these dependancies as long as they 
are of very little importance actually :

http://hpaste.org:80/fastcgi/hpaste.fcgi/view?id=8261

I added (line 291 to 309) the code needed to play Pentis but at this time the 
random generator bugs with 18 elements and only p12 is selected. Those who want 
to try can easily comment l.274 and decomment l.275 (then removing p17,p18 from 
the list because of the bug) and replace straight by p1 on l.80
Harder !



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Elerea/GLFW Tetris

2009-08-15 Thread Patai Gergely
 Here is my first real program in Haskell. 
How come you started out with playing around with FRP libraries right
away? It's a rather peculiar choice, I'd say.

 In fact, I'm not fully responsible because it's just an adapted
 version of a Tetris Creighton Hogg had written for Reactive/GLUT. 
 As the first version, it's a very simple game (no levels, no
 points ...) but it's playable !
It's an interesting exercise, and quite a nice job from someone who
considers themselves a beginner.

One thing I don't really understand is why you packed up those
applicative combinators in a SignalMonad, i.e. the reason behind flat
and sf_sa. You have much more freedom in using them as they are, since
they can appear inside any expression. For instance, you could just say
the following in the let declaration:

sfall = (uncurry . fall) $ randomBehavior seed
sid = pure id

Or even better, since both sfall and sid are created by pure
combinators, you don't even need to name them if they are used only once
anyway:

autumn = ifte metronome ((uncurry . fall) $ randomBehavior seed) (pure
id)

Another thing, which is really a matter of taste, is that you seem to
like point-free style acrobatics. I don't think it's always the best
choice, especially if you are to share code with others, since most
people grok code with explicit parameters easier than magic involving
flip and const and (un)curry and the like, except for the obvious cases
of composing a chain of operations, where dropping arguments feels quite
natural. For instance, the definition of f_a looks problematic to me
because of these concerns.

Gergely

-- 
http://www.fastmail.fm - Same, same, but different...

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Elerea/GLFW Tetris

2009-08-15 Thread jean legrand
 How come you started out with playing around with FRP
 libraries right
 away? It's a rather peculiar choice, I'd say.

I'm always curious about how the languages I study interact with OpenGL because 
I'm in the numerical simulation. When I came to Haskell on December, it was 
quite a new sensation at the functional level first (I knew Scheme but I never 
tried to find out how Scheme could interact with OpenGL!) and also about IO. 
But I liked it (and running). Then I studied Reactive but I had some problems 
installing it on Linux GHC6.6 so I was looking another library and I saw your 
post on March I think. But my knowledge about Haskell was too light at this 
time. Then I studied more and here I am!

 It's an interesting exercise, and quite a nice job from
 someone who
 considers themselves a beginner.

thanks, it took me a few days but as I said it was floating in my head for a 
few months.

 they can appear inside any expression. For instance, you
 could just say
 the following in the let declaration:
 
 sfall = (uncurry . fall) $ randomBehavior seed
 sid = pure id

yes, I saw sfall too late (however I haven't thought about sid, thanks)

 Another thing, which is really a matter of taste, is that
 you seem to
 like point-free style acrobatics. I don't think it's always
 the best
 choice, especially if you are to share code with others,
 since most
 people grok code with explicit parameters easier than magic
 involving
 flip and const and (un)curry and the like, except for the
 obvious cases
 of composing a chain of operations, where dropping
 arguments feels quite
 natural. For instance, the definition of f_a looks
 problematic to me
 because of these concerns.
 

I agree with you in general (point-free is unreadable), but in the case of f_a 
particularly, it took me a long time (not as long as for sf_a, however) to 
design it (not the point-free version but the raw one) and I think the 
point-free version is the best way to dissuade anyone to  try to hack it and to 
persuade her to write a new function which fits her needs. 
It is actually the reason why I called f_a  like this : because its two 
arguments are a function and a non-function argument (the first argument of 
sf_a is of course a signal of a function). This means I don't want to know how 
the machine works when I write my program. But it's a matter of taste as you 
said.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe