From 998ec0f6506d8b7065fbe277c253188b38bcac7c Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 10 Mar 2009 11:18:01 -0400 Subject: React demo --- demo/prose | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'demo/prose') diff --git a/demo/prose b/demo/prose index ab32a753..9c2639ff 100644 --- a/demo/prose +++ b/demo/prose @@ -191,3 +191,9 @@ alert.urp

Ur/Web makes it easy to write code whose execution should be distributed between the web server and client web browsers. Server-side code is compiled to efficient native code, and client-side code is compiled to JavaScript. Ur/Web programmers don't need to worry about these details, because the language and standard library provide a uniform ML-like interface for the whole process.

Here's an example of a button that, when clicked, opens an alert dialog on the client.

+ +react.urp + +

Most client-side JavaScript programs modify page contents imperatively, but Ur/Web is based on functional-reactive programming instead. Programs allocate data sources and then describe the page as a pure function of those data sources. When the sources change, the page changes automatically.

+ +

Here's an example where a button modifies a data source that affects some text on the page. The affected portion of the page is indicated with the pseudo-HTML tag dyn, whose signal attribute specifies one of these pure functions over mutable sources. A source containing data of type t has type source t and is created with the source operation within the transaction monad. Functions over sources are represented in the monad signal. Like in Haskell, we overload monad notations, so that the same return and bind operators can be used to write signals and transactions. The signal function coerces a source to a signal.

-- cgit v1.2.3