Download presentation
Presentation is loading. Please wait.
Published byKimberly Andrews Modified over 8 years ago
1
Feature-Level Modularity in Ur/Web Adam Chlipala WG 2.16 meeting, August 2013
2
2 Web programming is widely viewed as monkey work, filled with tedious boilerplate where mistakes have serious security consequences. Ur/Web Ur/Web supports modular programming to skip the boilerplate, with a compiler that understands the structure of web apps.
3
3 Ur/Web Functional Programming Dependent Types Meta- programming Compatibility with Web Standards & Browser Quirks Incorporating feature requests and patches from (quasi-)real- world users since 2008.
4
4 There are at least several users whom I have never met! The first commercial Ur/Web application: BazQux Reader, by Vladimir Shabanov Feed reader with comments http://www.bazqux.com/ On the order of 1000 active users
5
5 Web Server SQL Database Server Web Browser Ur/Web source code Tierless language: compile from one language to all tiers Page shown to user Database contents Communication channels with browsers Strongly typed syntax of embedded languages: SQL, HTML, CSS, URLs,... Classic HTTP requests, RPCs, push notification SQL updates, queries, and responses Automatic marshaling and network communication
6
6 Strong Encapsulation for the Web Private State Subtree of Displayed Document Client-side SQL Table of Recent Uploads RPC Handler Server-side Strong Interface Client render Callbacks: onSuccess, onError,... File Upload Widget Choose
7
7 Feature-Level Modularity Why stop at GUI widgets? Goal: Allow assembly of entire applications directly by composing modules standing for features that are meaningful to end users. Features could add: ● New columns to shared database tables ● New (private, encapsulated) tables ● New GUI widgets as part of particular views ● Completely new user-accessible operations ●…●… Want to be able to type-check features separately while guaranteeing that any composition has basic type-safety properties.
8
8 Example: Conference Management System Single- or double-blind reviewing? External review committee? One guardian in charge of each paper? Rebuttal? Rating scale? …. Author web interface Reviewer web interface Offline review form interface Web API for access by other systems …. Customized System
9
9 Secret Sauce: Type-Level Records First-class status for extensible record types Useful for: ● Modeling SQL table schemas ● Describing the results of a set of GUI widgets ● Representing typing environments of embedded languages Basic language ingredients: ● Record type (row) literals ● Row field name literals ● Concatenation of rows ● Reasoning about disjointness of rows ● Fancier: Computing with rows, using a higher-order map function
10
10 Row Type Ingredients con r1 = [A = int, B = float] val x1 : $r1 = {A = 1, B = 2.3} con r2 = [C = string] con r = r1 ++ r2 val x : $r = {A = 1, C = "q", B = 2.3}
11
11 Abstracting over Rows with Modules signature S = sig con r1 :: {Type} con r2 :: {Type} constraint r1 ~ r2 val fl1 : folder r1 val fl2 : folder r2 val r1_showable : $(map show r1) end structure M : S = struct con r1 = [A = int, B = float] con r2 = [C = string] end
12
12 Abstracting over Rows with Modules II functor Stringify(M : S) : sig val stringify : $(M.r1 ++ M.r2) -> string end = (* fancy dependent types footwork elided *) structure St = Stringify(struct con r1 = [A = int, B = float] con r2 = [C = string] end) val s = St.stringify x
13
13 Demo
14
14 Ur/Web Available At: http://www.impredicative.com/ur/ Including online demos with syntax-highlighted source code
15
15 Backup
16
16 Dependent Types? Level 1 Expose embedded languages as libraries, with type-checking via Ur/Web's own type checker. Level 2 Assign expressive static types to metaprograms, generic in e.g. database schemas.
17
17 Secret Sauce (s) ● Client-side GUI management via a variant of functional-reactive programming ● Client-side multithreading with blocking remote procedure calls ● Server push via typed message-passing channels
18
18 Ur/Web Interface Code type handle (* abstract type *) (* omitted code for claiming handles *) val render : {OnSuccess : handle -> transaction {}, OnError : transaction {} } -> transaction xbody
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.