[web-devel] WAI routing?

Stephen Paul Weber singpolyma at singpolyma.net
Sun Mar 18 01:45:32 CET 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Somebody claiming to be yi huang wrote:
>On Sat, Mar 17, 2012 at 11:06 AM, Stephen Paul Weber <
>singpolyma at singpolyma.net> wrote:
>I use plain case expression to do routing for my simple wai applications,
>ghc's desugar can make it more efficent than linear scan

Really?  That's interesting

>the code is like
>this:
>
>case (requestMethod req, pathInfo req) of
>    ("GET", []) -> index
>    ("GET", ["object", pk]) -> getObject pk
>    ("POST", ["object", pk]) -> jsonBody >>= updateObject pk
>    _ -> bad status404 "no route match"

Hmm, that may indeed solve many of my use cases, and is very nice looking.  
I assume this only works with -XOverloadedStrings, and that's why you can 
pattern match on Data.Text?

- -- 
Stephen Paul Weber, @singpolyma
See <http://singpolyma.net> for how I prefer to be contacted
edition right joseph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJPZTArAAoJENEcKRHOUZzedaEP/jzUSmrvTm6fWVpQOl9AOZoP
UebR3RdwqUGXNXE7dPGgSkdihRsD8h0ToOHziNpphj7fVDLY216zSes6rL4GGZIq
PL2HD6j0tW6GK/kQLwgYCoxNIy6v/E9FDppfuUDNNnPqloSIH4cTfvMVTLaVH434
yCR7bv202NckBeahmoFz/1xQh8pANijsrozNqz8vEifmzGbSt72/FqQ0d6oogOGk
QEQFTy9ctjf1740paual/pn0v+ESIuTQ+0yxJ0wiaxowmaCHZdkqiTK3ZTZLpaB9
teqjrdGpxaYG6X9Ldv6ZzztphvrlfS57daBidxoelG8jaLX+f7SeNnbg8v9PX/31
JXJmEkkG5Nn2hkWUqw+9sNKcpJRzWqyx/hQyhPBKiPYGDtvyY0aB1UT7hoATzCPF
QhPTVlyabx/53aKz6c7tXKrQGmRSQ1G163kJQzU682khhLUTvqL1u0ZFeEfdC3Bm
bOo+K9+32pOBFCPee51pgy6cg0SRk/Z+8miGz6bzh2EJ+iaxGX2KkhlXFI+1G5Hu
Cdnocehs0b1o9McAnHqAAgkrUov5HmY4akDkhzfbgP+4OgXtZn3j3nFlkU/MP46R
Pi+ZQvjTVGtD0AEIwh5X1EKPYWx8cGZSIGTHxPTP3uZav59urLrYBmk/VcTTOWls
Zt9s88iEIJ8Vgvm8V6P7
=i7R9
-----END PGP SIGNATURE-----



More information about the web-devel mailing list