Design
The HToolkit package is divided in two libraries: GIO and Port. The Port library is a low level interface and it is not intended to be used for development. Port includes modules written in C and FFI for them written in Haskell. GIO is a high level API intended for application development. The HToolkit is divided in high and low level in order to allow development of experimental high level interfaces without sacrifice of low level API.
The middle-level library is designed under the following constraints:
- Portable across platforms.
- Reasonably easy to use for a programmer.
- Everything is in the IO monad and mutable variables are used to model state.
- Rich enough to write useful application.
- Flexible enough to evolve into an industrial strength library.
- Flexible enough to be used as a basis for a high-level library (article).
The low-level GUI library, Port, should be:
- Portable across platforms.
- Reasonably easy to implement, but may less easy to use for a programmer.
- Rich enough to implement a middle-level GUI library.
- Expose target dependent handles for extensibility.
- Use only native controls and features provided from the concrete platform.
Currently, the Port library is just a thin marshalling layer upon a portable C-interface, with a C implementation for GTK and Windows. As such, the library may be of interest for other programming languages as well.
As we known the only other cross platform libraries that uses native controls are wxWindows for C++ and SWT for Java. The main differences between them and HToolkit are:
- The core level of HToolkit is written in C. This simplifies usage of core from high level languages (like Haskell). For examples usage of wxWindows or SWT from Haskell requires additional wrapper written in C around the original library.
- The wxWindows is a complete framework, while the HToolkit core contains only functions for GUI management. The wxWindows contains many utility and database classes that are helpful for C++ applications but are useless from other languages which usually has its own frameworks.