1 What is it?

LGtk is a lens-based API for Gtk.
LGtk is built on Gtk2Hs.

Most Haskellers would like to use a mature FRP-based API for creating graphical user interfaces.
FRP may not be the best tool for special user interfaces, like interfaces which consists of buttons, checkboxes, combo boxes, text entries and menus only.
LGtk has a lens-based API which fits better these user interfaces.

2 Semantics overview

The semantics of LGtk is given by a reference implementation.
The reference implementation is given in the following stages.

2.1 Lenses

LGtk use simple lenses, defined in the data-lens package:

newtype Lens a b = Lens { runLens :: a -> Store b a }

This data type is isomorphic to

(a -> b, b -> a -> a)

, the

well-know lens data type.

In certain places LGtk allows to use non-pure lenses, i.e. lenses which
brake lens laws. Those places are explicitly marked and explained in this overview.

2.2 References

A reference

Ref a

is isomorphic to

Lens s a

for some fixed state

s

.

TODO

2.3 Lens-trees

TODO

2.4 Effects

TODO

3 Examples

3.1 Hello World

main = runWidget $ label $return"Hello World!"

return

is neded because labels may be dynamic, see the next examples.

3.2 Copy

The following applications presents an entry and a label below of it.
When a text is entered in the entry, the label is changed to the entered text.