a minimal Windows program in Haskell?
How do I make a minimal Windows application in Haskell? I know there are Win API bindings in the libraries, and of course the ffi lets you call into and out of C, but I have no sense of how to bring it all together. I can't find any samples either. Is the Haskell code the "main" application and you just ffi into the Win API? Or does it ffi into a win_main.c that I write? Or is the win_main.c the "main" application and it calls into Haskell? Here is what I am talking about by a "minimal Windows application" (written in psuedo C code). #define WIN32_LEAN_AND_MEAN #include <windows.h> LRESULT CALLBACK windowsProcedure(..) { switch(message) { case WM_CLOSE: PostQuitMessage(0); return 0; } return DefWindowProc(..); } int APIENTRY WinMain(..){ WNDCLASS window_class; RegisterClass(&window_class) window = CreateWindow(..); ShowWindow(..); while(true) { /* do whatever */ while(PeekMessage(..)) if(msg.message == WM_QUIT) return msg.wParam; else DispatchMessage(&msg); } return 0; }
Hello Nun, Monday, November 3, 2008, 6:18:12 AM, you wrote:
How do I make a minimal Windows application in Haskell? I know
you should look at Win32 package sources which includes small example using WinAPI for "hello world" GUI application but note that Win32 binding is far from complete. if i will start to write WinAPI GUI app, i may prefer to do GUI part in C and communicate to Haskell part via FFI ps: http://www.haskell.org/ghc/dist/stable/dist/ghc-6.10.1-src.tar.bz2 ghc-6.10.1\libraries\Win32\examples -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
Bulat Ziganshin <bulat.ziganshin@gmail.com> wrote: ps: http://www.haskell.org/ghc/dist/stable/dist/ghc-6.10.1-src.tar.bz2 ghc-6.10.1\libraries\Win32\examples Thanks for this. I noticed some errors in the sample that might help others: 1) you need to replace "win32" with "Win32" in the given command line instruction 2) the Win32 package in this link gives a type error during the "setup build" phase (expecting exception and given ioerror?) but you can compile the example against the Win32 package in ghc 6.8.3
Hello Nun, Monday, November 3, 2008, 11:53:08 PM, you wrote:
2) the Win32 package in this link gives a type error during the "setup build" phase (expecting exception and given ioerror?) but you can compile the example against the Win32 package in ghc 6.8.3
of course - it's written against 6.10.1. you should download sources of your GHC version and use example from it. look in http://www.haskell.org/ghc/dist/stable/dist/old -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (2)
-
Bulat Ziganshin -
Nun Aurbiz