Embedded Languages for Graphical Programming - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Embedded Languages for Graphical Programming

Description:

Not always a monad. Fudgets. First 'real' GUI library for Haskell ... Not everything is a monad. Further Reading -- Take a look at ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 25
Provided by: Koen60
Category:

less

Transcript and Presenter's Notes

Title: Embedded Languages for Graphical Programming


1
Embedded Languages for Graphical Programming
  • Koen Lindström Claessen
  • Chalmers University
  • Gothenburg, Sweden

2
Topics Today
  • Fudgets Embedded language for GUI programming
  • Pan Embedded language for describing pictures
    and animations
  • Give you a flavor

3
Embedded Language
  • Library
  • Compositional
  • (Abstract) type -- modelling
  • Creation functions
  • Combinators
  • Not always a monad ?

4
Fudgets
  • First real GUI library for Haskell
  • Developed in 1990s (pre-monad era)
  • Magnus Carlsson
  • Thomas Hallgren
  • Still active

5
The Fudget
Messages of type a, b functional behavior
a
b
Also a graphical representation
type F a b
6
Example A Button
()
()
Hello
button String -gt F () ()
7
Example An Entry
String
String
12.0
entry F String String
8
Fudget Composition
a
b
c
(gtlt) F a b -gt F b c -gt F a c
9
Fudget Composition
a
b
c
a
(gtlt) F a b -gt F a b -gt F a b
10
Example An Abstract Fudget
a
b
mapF (a -gt b) -gt F a b
11
Example Spinner
12
Example
13
Example
spin F a (Int -gt Int) spin nil gtlt (
button gtlt mapF (\_ -gt succ) gtlt button
- gtlt mapF (\_ -gt pred) ) spinner
F Int Int spinner loop ( (mapF const gtlt
spin) gtlt count gtlt entryInt
)
nil ignores input
loop ties the knot
count does the counting
14
Fudgets -- Summary
  • Pick the thing to model
  • A Fudget
  • Widget Functionality
  • Pick a type
  • Design combinators

15
Implementing Fudgets
  • Shallow embedding?
  • Deep embedding?

16
Pan Functional Images
17
Embedded Language for Images
type Point (Double,Double) type Image a Point
-gt a
type Region Image Bool
type Color ... type Picture Image Color
18
Examples
vstrip Region vstrip (x,y) abs x lt 0.5
checker Region checker (x,y) even (floor
x floor y)
altRings Region altRings p even (distO
p) distO (x,y) sqrt (xx yy)
19
Liftings
lift1 (a -gt b) -gt Image a -gt Image b lift2
(a -gt b -gt c) -gt Image a -gt Image b -gt Image c ...
over Picture -gt Picture -gt Picture over
lift2 overColor
cond Region -gt Picture -gt Picture -gt
Picture cond lift3 (\b x y -gt if b then x else
y)
20
Swirling
type Filter a Image a -gt Image a
swirl Double -gt Filter a swirl r im im
. (\p -gt rotate (distO p 2 pi / -r) p
21
Image Viewer
  • There is an image viewer
  • You can set parameters
  • Sliders
  • Time

22
Implementation?
  • How to implement this efficiently?
  • Shallow implementation?
  • Deep implementation?

23
What we saw
  • Embedded Languages
  • Graphics
  • Compositional
  • Shallow embedding for understanding
  • Deep embedding can be compiled
  • Not everything is a monad

24
Further Reading -- Take a look at
  • Fran Functional Reactive Animations
  • Yampa Fran (version 2)
Write a Comment
User Comments (0)
About PowerShow.com