Advertisement
Guest User

Untitled

a guest
Jun 17th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. {-# LANGUAGE RecursiveDo #-}
  2. import Control.Applicative
  3. import Control.Monad
  4. import Data.Maybe
  5.  
  6. import qualified Graphics.UI.Threepenny as UI
  7. import Graphics.UI.Threepenny.Core
  8.  
  9. main :: IO ()
  10. main = startGUI defaultConfig setup
  11.  
  12. setup :: Window -> UI ()
  13. setup w = mdo
  14. return w # set UI.title "Simple example"
  15.  
  16. display <- UI.textarea # set UI.text "Initial value"
  17. listBox <- UI.listBox (pure ["first", "second"]) listB ((UI.string .) <$> (pure id))
  18. listB <- stepper Nothing (rumors $ UI.userSelection listBox)
  19. button <- UI.button # set UI.text "Button"
  20. cutedListB <- stepper Nothing (listB <@ UI.click button)
  21.  
  22. element listBox # set (attr "size") "10"
  23.  
  24. getBody w #+ [element listBox, element button, element display]
  25.  
  26. on UI.click button $ const $ do
  27. element display # sink UI.text ((maybe "new text" id) <$> cutedListB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement