2019-11-27 20:14
Page 1

Graphical User Interfaces in Haskell

Page 2

Graphical User Interface Libraries

Several libraries for Graphics and GUIs can be found on Hackage:

Page 3

Today: threepenny-gui

Page 4

First: HTML and JavaScript

Page 5


Page 6

Making web pages more dynamic

Page 7

JavaScript Example

Page 8

User interface elements

Page 9

Adding functionality

Adding an event handler for the button

Page 10


Page 11

threepeny-gui first example

Page 12



mkButton :: String -> UI Element
mkButton label =
  do button <- mkElement "input"
     button # set (attr "type") "button"
     button # set (attr "value") label
     return button
Page 13

Event handlers


counterExample w =
  do input <- mkElement "input"
     button <- mkButton "Increment"
     getBody w #+ [element input,element button]
     let incr _ = do s <- input # get value
                     let v = read s
                     input # set value (show (v+1))
     on click button incr
Page 14

GUI programming in a functional style?

Page 15


Page 16

What is a Fudget?

Page 17
What is a Fudget?
Page 18
What is a Fudget?
Page 19
What is a Fudget?
Page 20
What is a Fudget?

Pure functions as fudgets

Page 21

ThreepennyFudgets Demo

Page 22

See also

Page 23
See also