Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Slides and code samples for talk at Scala Lift-Off London 2011.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
0-slides
1-args
2-hlists
3-paths Re-renamed PArg to PMatch to match slides.
4-routes Re-renamed PArg to PMatch to match slides.
5-sites Re-renamed PArg to PMatch to match slides.
6-implicits Re-renamed PArg to PMatch to match slides.
7-lift-app Re-renamed PArg to PMatch to match slides.
.gitignore
README.md Added link to talk video on Skills Matter.
sbt-launch.jar HList example

README.md

A Route To The Three 'R's: Reading, Writing and the REST

Slides, notes and code samples for my talk at Scala Lift-Off London 2011.

Abstract

The mappings between URLs and code form an integral part of any web application. Many web frameworks help map from URLs to code, but the reverse mapping is often neglected, leaving developers to construct URLs via haphazard string manipulation. Furthermore, many frameworks do not match URLs in a type-safe manner.

Scala provides all the tools we need to address this problem in a more comprehensive manner. In this talk we will walk through the creation of Bigtop Routes, a bidirectional mapping library that is both type-safe and developer-friendly. We will pay particular attention to the ways in which Scala language features, such as flexible syntax, implicit conversions, and a touch of type-level programming, help to simplify the task at hand.

Video and Slides

Skills Matter have posted a video of the talk here:

The slides are available here:

Code

In the talk I build the routes library in stages from the ground up. There is a code sample associated with each stage. In each case I recommend you check out the unit tests to see what's going on, and then invoke the Scala console to play with the code yourself. For example:

bash$ cd 1-args                            # change to the example directory


bash$ ls src/test/scala                    # see what test files there are
ArgSpec.scala


less src/test/scala/ArgSpec.scala          # have a look at the tests to see what's going on
<< file contents appears here >>


./sbt test                                 # run the tests to check it all works
[info] Set current project to 1-args (in build file:/blah/blah/1-args/)
[info]   + IntArg.encode encodes as expected
[info]   + IntArg.decode decodes integers correctly
[info]   + IntArg.decode only decodes integers
[info]   + StringArg.encode does not (un)escape reserved characters
[info]   + StringArg.decode does not (un)escape reserved characters
[info] Passed: : Total 5, Failed 0, Errors 0, Passed 5, Skipped 0
[success] Total time: 4 s, completed Oct 10, 2011 3:54:14 PM


./sbt console                              # start an interactive shell to try it for yourself
[info] Set current project to 1-args (in build file:/blah/blah/1-args/)
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.


scala> IntArg.decode("123")                # run some Scala commands to see what happens
res0: Option[Int] = Some(123)


scala> :quit                               # quit the Scala console

Licence

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Something went wrong with that request. Please try again.