module Tvar:`sig`

..`end`

Transform variables

Transform variables are a way to share a common data between two widgets,
when the data has a different meaning (or even a different type) for each
widget. One widget holds the original value, and the other widget needs to
apply a *transformation* each time it wants to read or modify the value.

For instance you want to share a bank account `b`

between Alice in France
and Bob in the USA. The value is stored by Alice in EUR, and when Bob does
`get b`

, he gets the value in USD. Similarly, if he does `set b 50`

to put
50USD on the account, then Alice's value will automatically have the amount
in EUR.

What is interesting is that the transformation functions can also have * side-effects*. For instance, send an email each time Bob or Alice modifies
the amount.

A more prosaic example would be a slider which shares its value as an integer between 0 and 100, and another widget which needs to read/save this value as a float between 0 and 1, and each one of them gets notified when the other changes the value.

`type ``('a, 'b)`

t

a transform variable of type `('a,'b)`

is a variable of type `'b`

attached
to a variable of type `'a Var.t`

by a bi-directional transformation.

`val create : ``'a Var.t ->`

t_from:('a -> 'b) -> t_to:('b -> 'a) -> ('a, 'b) t

`val get : ``('a, 'b) t -> 'b`

`val set : ``('a, 'b) t -> 'b -> unit`