Small JAPI binding for GHC in CVS

Hi there. Under "fptools/libraries/Japi" (the GHC CVS repository) please find a preliminary binding to a subset of the Japi library: http://www.japi.de/ from which site you can obtain precompiled libraries and headers for different platforms. Japi is a simple C wrapper on Java which means that either "jre" or "java" needs to be in your path, but it avoids callbacks and uses the Haskell 98 FFI so I would expect it to be easy to port to "nhc98". You have to do an event loop in Haskell. The makefiles have been tested with MinGW32 GHC, but I expect you would need little effort under Linux, for example. Some examples are provided including a Fractal program, based on the C originals including the one below which will probably have mangled formatting courtesy of Outlook. Cheers Mike Thomas. --------------------------------------------------- module Main(main) where import Graphics.UI.Japi.Binding import Graphics.UI.Japi.Types import Graphics.UI.Japi.Constants import Control.Monad main = do j_setdebug 4 rv <- j_start when (0 == rv) (error "Could not start the JAPI server (jre or java)") frame <- j_frame "Frame demo" j_show (Object $ fromIntegral $ frame) icon <- j_loadimage "../c-examples/images/new.gif" when (0 == icon) (error "Could not find the icon file.") j_seticon frame icon waitForFrameAction frame return j_quit waitForFrameAction :: Frame -> IO () waitForFrameAction frame = do rv <- j_nextaction when (not (rv == (EventListener $ fromIntegral $ frame))) (waitForFrameAction frame) return ()

"Mike Thomas"
Under "fptools/libraries/Japi" (the GHC CVS repository) please find a preliminary binding to a subset of the Japi library:
Looks useful.
it avoids callbacks and uses the Haskell 98 FFI so I would expect it to be easy to port to "nhc98".
Unfortunately, the module Graphics.UI.Japi.Types uses a ghc-only extension: deriving on newtypes for the classes Integral, Real, Num, and Enum. If it wasn't for that, it would be very portable. Regards, Malcolm

Thanks Malcolm. | Unfortunately, the module Graphics.UI.Japi.Types uses a ghc-only | extension: deriving on newtypes for the classes Integral, Real, | Num, and Enum. If it wasn't for that, it would be very portable. Woops. I'll try and work out a way of fixng that up after I get the GNU Common Lisp Windows installer out of the way over the coming week. I'm a half baked Haskeller, so suggestions on how best to type the interface are welcome. Cheers Mike Thomas.
participants (2)
-
Malcolm Wallace
-
Mike Thomas