SLIDE 13 .
.
.
Binding Raphael.js
.
/
. Static Typing & JavaScript Libraries . WWW . / . The generated interface:
: module Data : s i g : type ' a key : val make_key : unit −> ' a key : val get element −> ' a key −> ' a option : val set element −> ' a key −> ' a −> unit : val remove −> ' a key −> unit : end
An example use:
: l e t color = Data . make_key ( ) in : (* a l l o c a t e s a new ' a key *) : Data . set e l t color " blue " ; : (* when f i r s t used , the type parameter i s fixed *) : (* color passes from [ ' a key ] to [ s t r i n g key ] *) : Data . set e l t color
(* w i l l produce an error at compile time : *) : (* types [ i n t key ] and [ s t r i n g key ] incompatible *)