ivanperez-keera / SpaceInvaders

A Haskell game written in Yampa
BSD 3-Clause "New" or "Revised" License
26 stars 16 forks source link

won't build; Windows + Haskell Platform #31

Closed g-pechorin closed 1 year ago

g-pechorin commented 6 years ago

Neither the "master" or "development" branch build. Both seem to fail with a chorus of errors such as;

Can you advise on how to fix this?

Graphics\HGL\Win32\WND.hs:243:37: error:
    * Couldn't match type `Foreign.C.Types.CIntPtr'
                     with `GHC.Int.Int32'
      Expected type: LONG
        Actual type: LPARAM
    * In the expression: x
      In the first argument of `toPoint', namely `(x, y)'
      In the `pt' field of a record
    |
243 |         send (Button {pt = toPoint (x,y), isLeft=isLeft, isDown=isDown})
    |                                     ^

Graphics\HGL\Win32\WND.hs:260:43: error:
    * Couldn't match type `Foreign.C.Types.CIntPtr'
                     with `GHC.Int.Int32'
      Expected type: LONG
        Actual type: LPARAM
    * In the expression: y
      In the first argument of `toPoint', namely `(x, y)'
      In the `pt' field of a record
    |
260 |         send (MouseMove { pt = toPoint (x,y) })
    |                                           ^
g-pechorin commented 6 years ago

This is the output of

$ cabal install SpaceInvaders

invaders.txt

ivanperez-keera commented 6 years ago

This seems to be an HGL problem. Maybe @xpika knows the answer to this one?

ivanperez-keera commented 6 years ago

The problem seems to be in a different package, not SpaceInvaders. That's why I mentioned someone else.

A workaround, which is not really a solution, could be:

Extract HGL in a directory with:

$ cabal unpack HGL
$ cd HLG-*/

Modify those files to convert between number types. Most likely, it'll be enough if you add fromIntegral before x and y in those expressions (as in (fromIntegral x, fromIntegral y)).

Finally, go to where you were before (presumably, cd ..) and do:

$ cabal install HGL-*/

EDIT: Missing last part of the instructions.

g-pechorin commented 6 years ago

That fixes some errors, but, I'm left with another error from HGL

   Module `Control.Concurrent.Chan' does not export `isEmptyChan'
ivanperez-keera commented 6 years ago

Aha. The function isEmptyChan was deprecated many moons ago (in base 4.5, which accompanied GHC 7.4, released in 2012) and finally eliminated in this year (in base 4.11, with GHC 8.4, released in 2018).

I two non-exclusive ways to move forward:

a) Change the cabal file and indicate an incompatibility with base 4.11 and higher.

b) Change the implementation to use the solution recommended in [1].

Would you (or anybody) want to help with this?

[1] http://hackage.haskell.org/package/base-4.10.1.0/docs/Control-Concurrent-Chan.html

ivanperez-keera commented 6 years ago

(These would be changes in HGL, not SpaceInvaders.)

g-pechorin commented 6 years ago

I setup a stack build and got it to build on Windows with specific versions of the dependencies.

Now it crashes on launch complaining that a window was destroyed in a different thread from the one that it was created in.

ivanperez-keera commented 6 years ago

I don't immediately find anything in SpaceInvaders that uses threads, so I don't know where that can come from. But I don't use Windows or stack, so I don't know what may be going on over there.

You can try to modify the cabal file and eliminate the threaded option to compile with the non-threaded RTS. I'm not sure if this can make a difference (meaning I'm not sure if Haskell's light threads can be causing this specific problem), but it's worth the try.

See: https://github.com/ivanperez-keera/SpaceInvaders/blob/develop/SpaceInvaders.cabal#L19

ivanperez-keera commented 1 year ago

It's been 5 years. I don't have a windows machine available, and I don't think the Haskell Platform is being advertised as the way to install haskell anymore, so I'm going to close this.

If this is still a problem, please re-open. Thanks!

chansey97 commented 9 months ago

This is HGL's issue. I have fixed it via the repository https://github.com/chansey97/HGL.