Hi
Inspired by FunctionalForms [1] and the scrap your boilerplate papers
[2], I have made a function which only needs an existing window and an
instantiated type as input to create a GUI form. However, this is just
an early prototype and needs a lot more work to become truly useful.
The function, mentioned above, has the following signature:
genericDialog :: (Data a) =3D> Window w -> a -> IO (Maybe a)
As a short example:
data SimplePerson =3D SimplePerson { name :: String, age :: Int }
deriving (Show, Typeable, Data)
main =3D start $
do w <- frame [text :=3D "Generic forms!"]
genericDialog w (SimplePerson "Some name" 117)
which will create a dialog, where the user can set the name and age of a
SimplePerson. Depending on user input, the function returns either
Nothing or a SimplePerson with possibly changed fields. A larger example
are in one of the two attached files. The other file contains the source
code for the library.
As mentioned above, this is just an early prototype and therefore a lot
of features are missing. It is currently not usable for a production
system. And it may never be possible to create forms in this way, and
still be useful in a production system. However, with further
development I believe this kind of library, should at least be able to
speed up prototyping GUI applications.
This library was tested on Debian stable (with some package from
unstable). I am using GHC 6.4 and wxHaskell 0.9.4.1. The library will
_not_ compile on GHC 6.2 or older.
The library can be compiled with:
ghc --make -package wx -fglasgow-exts AFPerson.hs
Greetings,
Mads Lindstr=F8m
[1] http://www.sandr.dds.nl/FunctionalForms/index.html
[2] http://www.cs.vu.nl/boilerplate/
|