XTC on hackage

Posted on 15 March 2008
Tags: wxhaskell

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. 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

Navigation

Comments