RE: Hugs on Mac with CW6 ? ... and Haskell Graphics Lib?
I'm surprised at the preference of GreenCard over H/Direct. H/Direct was designed as an evolution of GreenCard based on experience with it, and has a strong foundation, as described in ICFP '98. The home page is http://haskell.org/hdirect. I don't know about its status relative to the Mac. Maybe Sigbjorn could comment. Cheers, - Conal -----Original Message----- From: Alastair Reid [mailto:reid@cs.utah.edu] Sent: Thursday, December 07, 2000 12:43 PM To: Doug Landauer (by way of Hans Aberg); Hugs Bugs Subject: RE: Hugs on Mac with CW6 ? ... and Haskell Graphics Lib? [Hugs Users removed from Cc list. Messages about machine support traditionally go to hugs bugs only. Also, since hugs-bugs members are supposed to be in hugs-users also, listing both is redundant.]
Unfortunately, I could not find any Mac port of the Haskell Graphics Library.
I'm afraid there isn't one. I have access to Unix and to Windows but not to a Mac. (Also I don't know the Mac API.)
Once I can get a plain Hugs working with CW 6, I'm hoping to try to figure out how to get it to interface to C, so I could supply something like the Haskell Graphics Library and link it in with Hugs.
Let me describe a few major steps in being able to write (or port) something like the HGL for the Mac: 1) Get Hugs working (obviously) 2) Learn how to use one of the many Hugs Foreign Function Interfaces (FFIs) on the Mac. Choices: 1) Directly modify builtin.c in the Hugs distribution. Tedious, error-prone, not recommended. 2) Use GreenCard (http://www.dcs.gla.ac.uk/fp/software/green-card/) Stable, simple, limited level of support (none?) Requires you to find out how to build the Mac equivalent of shared libraries (Unix terminology) or DLLs (Windows terminology). (Looking at the Hugs sources, it appears that the answer is a .pef file and that someone has figured this out before - hopefully someone can send instructions in response to this message.) 3) Use H/Direct (http://haskell.cs.yale.edu/haskellscript/hdirect.html) Easy to use if you already have a COM/IDL specification of the API you want to use. It's not clear whether it's still supported since the above page says the real home page is at: http://www.dcs.gla.ac.uk/fp/software/hdirect which is a broken link. 4) Use the FFI standard (http://haskell.cs.yale.edu/definition/ffi/) possibly in conjunction with some of the ffi tools/libraries that have come out such as Manuel Chakravaty's C->Haskell library (http://www.cse.unsw.edu.au/~chak/haskell/c2hs/) This is the preferred option. There's just one small problem that I'll expand on below. 5) Consult Haskell.org (http://haskell.org/libraries/#interfacing) Of these, I strongly recommend (4) with (2) as a second choice. The one small problem with (4) is that the official Hugs distribution does not support the FFI standard. However, there is an unofficial Hugs distribution which does support it. You can download it from my home page: http://www.cs.utah.edu/~reid/tmp/hugs98-ffi-03122000.tgz If you need to use foreign export dynamic, you will need to write a small machine code stub for your architecture. 3) Learn how to write simple graphical programs in C for the Mac. By simple I mean how to do things like: Hello World (where the text appears centred on a window). A simple drawing program that puts a black pixel on the screen if the mouse button is depressed. Responds to simple keyboard input. Responds to periodic and/or one-shot timers. 4) Use your choice of FFI to translate your simple C programs into Haskell. 5) Contact me for help on understanding the code in the Hugs Graphics Library (or for hints on how to produce something equivalent). (There's someone else trying to port the HGL to GHC so a 3-way discussion might arise.) [The above list could take a while to work through and might be best tackled by a team of people rather than just one person who is new to Haskell. The HGL and all the associated tools, libraries and techniques I had to develop to write it was spread out over a period of about 5 years.]
-- would it be easier to work with GHC or HBC instead of Hugs?
It would be easier in that both have mature implementations of the ffi. However, I don't know if either of them has been ported to the Mac yet. If the answer is no, I think it would be significantly easier to work with Hugs. (This belief is based on lots of experience with Hugs and GHC. I know very little about HBC.) -- Alastair Reid _______________________________________________ Hugs-Bugs mailing list Hugs-Bugs@haskell.org http://www.haskell.org/mailman/listinfo/hugs-bugs
I'm surprised at the preference of GreenCard over H/Direct. H/Direct was designed as an evolution of GreenCard based on experience with it, and has a strong foundation, as described in ICFP '98.
Perhaps I should admit a certain bias: GreenCard is partly my creation so I have a soft spot for it... H/Direct would be the tool of choice if you happen to have IDL descriptions of the Mac graphical API. Given Microsoft's interest in the Mac, it is possible that these already exist. Lacking an IDL description, my tool of choice would be to use the FFI directly and use a suitable ffi library to take care of the tedium (and/or to use c2hs) GreenCard would probably never have come into existence if the current ffi specification had already existed. -- Alastair Reid
Use whatever tool you feel comfortable with and does the job for you, would be my suggestion. But, HDirect isn't solely based around IDL as a specification language, it processes C header files too (you can specify IDL attributes separately from the header file declarations, if needed.) Supports both CPP GNUisms and MSisms. --sigbjorn ----- Original Message ----- From: "Alastair Reid" <reid@cs.utah.edu> To: "Conal Elliott" <conal@microsoft.com>; "Doug Landauer (by way of Hans Aberg)" <landauer@scruznet.com>; "Hugs Bugs" <hugs-bugs@haskell.org>; "Sigbjorn Finne (E-mail)" <sigbjorn_finne@hotmail.com> Sent: Friday, December 08, 2000 05:36 Subject: RE: Hugs on Mac with CW6 ? ... and Haskell Graphics Lib?
I'm surprised at the preference of GreenCard over H/Direct. H/Direct was designed as an evolution of GreenCard based on experience with it, and has a strong foundation, as described in ICFP '98.
Perhaps I should admit a certain bias: GreenCard is partly my creation so I have a soft spot for it...
H/Direct would be the tool of choice if you happen to have IDL descriptions of the Mac graphical API. Given Microsoft's interest in the Mac, it is possible that these already exist.
Lacking an IDL description, my tool of choice would be to use the FFI directly and use a suitable ffi library to take care of the tedium (and/or to use c2hs) GreenCard would probably never have come into existence if the current ffi specification had already existed.
-- Alastair Reid
participants (3)
-
Alastair Reid -
Conal Elliott -
Sigbjorn Finne