Ur supports a powerful kind of metaprogramming based on row data types.5
Ur/Web is Ur plus a special standard library and associated rules for parsing and optimizing. Ur/Web supports construction of dynamic web pages and applications backed by SQL databases. The signature of the standard library is such that well-typed Ur/Web programs "don't go wrong" in a very broad sense. They do not crash during particular page generations, and may not:6
This type safety is just the foundation of the Ur/Web methodology. It is also possible to use metaprogramming to build significant application pieces by analysis of type structure.7
The Ur/Web compiler also produces very efficient object code that does not use garbage collection.8
SQL syntax templates embedded in the language facilitate the handling of tables.
Although the syntax is based on Standard ML the language includes concepts from Haskell with added type manipulation.
Ajax call/response is serialized through a monad called transaction (corresponds to Haskell's input/output (IO)) and its marshalling and decoding is encapsulated in the rpc function.
The browser client side includes functional reactive programming facilities using the (source a) type and a signal monad.
This is a demo program showing client, server and database code with Ajax communication, from the web demos,9 with extra comments to outline each of the components:
Interface file (ML-like signature) with .urs extension:
Implementation file (.ur extension):
Project file (.urp extension), must contain an optional directive list followed by a listing of project modules:10
Compile:
Execute as a web server (other modes are CGI, FastCGI, ...):
corresponding signature (kind annotations (:::) implicit; (::) explicit):
This error happens with types of arity > 0 in nested case or let clauses and disappears by type annotating the variables in the nested clauses.
Chlipala, Adam (January 2015). "Ur/Web: A Simple Model for Programming the Web". MIT / Association for Computing Machinery (ACM). Retrieved 5 January 2015. https://dspace.mit.edu/handle/1721.1/92321 ↩
"The Ur Programming Language Family". Impredicative.com/ur. Retrieved 3 April 2016. http://impredicative.com/ur/ ↩
Chlipala, Adam (2006). "The Laconic programming language family". SourceForge. https://laconic.sourceforge.net/ ↩
Chlipala, Adam (2006). "Scrap Your Web Application Boilerplate, or Metaprogramming with Row Types". Adam.Chlipala.net. http://adam.chlipala.net/papers/LaconicTR/ ↩
Ur language demo programs http://impredicative.com/ur/demo/ ↩
Chlipala, Adam (January 2015). "The Ur/Web Manual – Project files". GitHub. Retrieved 8 January 2015. https://enn.github.io/urweb-doc/node5.html ↩
The Ur/Web Manual - The Structure of Web Applications https://enn.github.io/urweb-doc/node54.html ↩
Unexpected type error: "Substitution in constructor is blocked by a too-deep unification variable" http://www.impredicative.com/pipermail/ur/2011-January/000498.html ↩