Hobby-hacking Eric


XTC on hackage

Just a quick note to say that XTC (XTC: eXtended & Typed Controls for wxHaskell) is available on hackage.

the haddock

The XTC library provides a typed interface to several wxHaskell controls.
  • radio view (typed radio box)
  • single-selection list view (typed single-selection list box)
  • multiple-selection list view (typed multiple-selection list box)
  • choice view (typed choice box)
  • value entry (typed text entry)
XTC controls keep track of typed values and items, rather than being string based. Selections in XTC controls consist of actual values instead of indices.

my notes

XTC library was developed in Utrecht University, and has been used to develop Dazzle, a Bayesian Network toolbox, and very much a "real world" application. You can read more about XTC and Dazzle in their Haskell Workshop paper from 2005.

If you're using wxhaskell, XTC could make your code a bit cleaner, without imposing a steep learning curve. Here is a quick example of the library in action.

And here is the source code. Notice how we work directly with the Fruit type, eschewing any intermediary strings:
import Graphics.UI.WX
import Graphics.UI.XTC

data Fruit = Apple | Banana | Orange deriving Show

instance Labeled Fruit where
toLabel = show

main :: IO ()
main = start $
do f <- frame []
txt <- staticText f [ text := "pick a fruit and I will give you a slogan" ]
radioV <- mkRadioView f Vertical [Apple, Banana, Orange] []
set radioV [ on select :=
do mf <- get radioV typedSelection
set txt [ text := slogan mf ]]
set f [ layout := margin 5 $ column 1
[ hfill $ widget txt, widget radioV ] ]

slogan :: Fruit -> String
slogan Orange = "orange you glad I didn't say 'orange'?"
slogan Apple = "an apple a day keeps, well you know"
slogan Banana = "buh-naaaaa-naaa"

If you like this kind of thing, be sure to also check out AutoForms and Phooey


wxhaskell 0.10.3rc1

In case you missed Jeremy's announcement, the first release candidate for wxhaskell 0.10.3 is now ready for download.

Highlights of 0.10.3 rc1 include:

  • Support for Unicode builds of wxWidgets
  • Support for wxWidgets 2.6.x (support for wxWidgets 2.4.2 retained if
    you compile from source)
  • Support for building with GHC 6.6.x and 6.8.x
  • Parts of wxHaskell are now built with Cabal
  • Profiling support
  • Smaller generated binary sizes (using --split-objs)

See Jeremy's message for a more complete list.

Note that we have postponed the goal of supporting wxWidgets 2.8. We are definitely making this a priority for wxhaskell 0.11. In the meantime, we will focus on making wxhaskell 0.10.3 easy for everyone to install. So please let us know if you run into any trouble. (Many thanks to Neil Mitchell and other users who have helped in testing)

Finally, users of MacOS X Leopard have reported difficulty building the older wxWidgets 2.6. According to the wxWidgets wiki page for more details), doing so is indeed possible, if you use the Tiger SDK. We would love to hear from you if you have succeeded in doing this.