IO
cabal install threepenny-gui
(or with stack
).
import Graphics.UI.Threepenny
string :: String -> UI Element -- a text element mkElemement :: String -> UI Element -- createElement (#+) :: UI Element -> [UI Element] -> UI () -- appendChildren getBody :: Window -> UI Element -- document.body startGUI :: Config -> (Window -> UI ()) -> IO ()
Element
UI
Elements
mkButton :: String -> UI Element mkButton label = mkElement "input" # set (attr "type") "button" # set (attr "value") label
#
x # f = f x
set
set'
counterExample w = do input <- mkElement "input" button <- mkButton "Increment" getBody w #+ [element input,element button] let increment _ = do s <- input # get value let v = read s input # set' value (show (v+1)) on click button increment
on
read
show
String
Int
type Canvas = Element
canvas :: UI Canvas -- create a canvas element
type Point = (Double,Double)
beginPath :: Canvas -> UI ()
moveTo, lineTo :: Point -> Canvas -> UI ()
closePath :: Canvas -> UI ()
stroke, fill :: Canvas -> UI ()
fillText :: String -> Point -> Canvas -> UI ()
arc
fillRect
lineWidth
strokeStyle
fillStyle
textFont
String
import Data.IORef -- a standard library module newIORef :: a -> IO (IORef a) -- create and initialize writeIORef :: IORef a -> a -> IO () -- update readIORef :: IORef a -> IO a -- read
IO
liftIO
IO
UI