comparison demo/prose @ 416:679b2fbbd4d0

Counter demo
author Adam Chlipala <adamc@hcoop.net>
date Thu, 23 Oct 2008 11:59:48 -0400
parents 6a0e54400805
children e0e9e9eca1cb
comparison
equal deleted inserted replaced
415:777317e8b2ae 416:679b2fbbd4d0
42 42
43 rec.urp 43 rec.urp
44 44
45 <p>Crafting webs of interlinked pages is easy, using recursion.</p> 45 <p>Crafting webs of interlinked pages is easy, using recursion.</p>
46 46
47 counter.urp
48
49 <p>It is also easy to pass state around via functions, in the style commonly associated with "continuation-based" web servers. As is usual for such systems, all state is stored on the client side. In this case, it is encoded in URLs.</p>
50
51 <p>In the implementation of <tt>Counter.counter</tt>, we see the notation <tt>{[...]}</tt>, which uses type classes to inject values of different types (<tt>int</tt> in this case) into XML. It's probably worth stating explicitly that XML fragments <i>are not strings</i>, so that the type-checker will enforce that our final piece of XML is valid.</p>
52
47 form.urp 53 form.urp
48 54
49 <p>Here we see a basic form. The type system tracks which form inputs we include, and it enforces that the form handler function expects a record containing exactly those fields, with exactly the proper types.</p> 55 <p>Here we see a basic form. The type system tracks which form inputs we include, and it enforces that the form handler function expects a record containing exactly those fields, with exactly the proper types.</p>
50
51 <p>In the implementation of <tt>handler</tt>, we see the notation <tt>{[...]}</tt>, which uses type classes to inject values of different types (<tt>string</tt> and <tt>bool</tt> in this case) into XML. It's probably worth stating explicitly that XML fragments <i>are not strings</i>, so that the type-checker will enforce that our final piece of XML is valid.</p>
52 56
53 listShop.urp 57 listShop.urp
54 58
55 <p>This example shows off algebraic datatypes, parametric polymorphism, and functors.</p> 59 <p>This example shows off algebraic datatypes, parametric polymorphism, and functors.</p>
56 60