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. The isomorphism is established by the following operations:

getL :: Lens a b -> a -> b

setL :: Lens a b -> b -> a -> a

lens ::(a -> b)->(b -> a -> a)-> Lens a b

2.1.1 Lens laws

The three well-known laws for lenses:

get-set:

set k (get k a) a

===

a

set-get:

get k (set k b a)

===

b

set-set:

set k b2 (set k b1 a)

===

set k b2 a

Impure lenses, i.e. lenses which
brake lens laws are allowed in certain places. Those places are explicitly marked and explained in this overview.

2.2 References

It is convenient to use lenses with the state monad
(see this use case) and the reader monad.

Let's call a value with type

Lens s a

a reference of the state monad

State s

and the reader monad

Reader s

.
References are distinguished from lenses, because we would like to make the program state

s

unaccessible to guarantee linear use of the state for example.

There are several ways to model references in Haskell.
LGtk models them as type classes with associated types, but that is just a technical detail.