AutoForms-0.4.0: src/Examples/HCron/Editor1st.hs
{-# LANGUAGE FlexibleContexts, FlexibleInstances
, MultiParamTypeClasses, PatternSignatures
, TemplateHaskell, UndecidableInstances #-}
module Editor1st where
import Entry1st
import Graphics.UI.AF.WxFormAll
import Control.Monad.Trans(liftIO)
$(derive [''Entry,''Time,''Month])
instance ECCreator (Entry HCron)
main = startWx "Editor1st" $
do entryValue :: HCron <- liftIO $ (readFile specLocation >>= readIO) `catch` (\_ -> return [])
entry <- builderCom entryValue
chState <- makeChangedState entry
let saveFile = do x <- getValue entry
liftIO $ writeFile specLocation $ show x
setValue chState $ Unchanged x
button "Save" saveFile >>= enabledWhen chState (== Changed)
button "Quit" closeWindow