The library Fmlib_browser helps to write web applications which run in the browser in a pure functional style. It mimics the elm language in ocaml.
The core of a functional web application is a system state and 2 main functions to describe the behaviour of a web application.
unit value (). For an application representing a counter which can be increased or decreased by clicking on buttons the state is an int which represents the value of the counter.If we just want to display a static page with a grocery list the functions are quite simple.
type message (* no constructor, i.e. no message can be created. *)
let view (): unit Html.t =
let open Html in
ol [] [
text "Milk";
text "Honey";
text "Meet"
]
let update () (_: message): unit =
assert false (* Function can never be called because [message] has no
constructor *)