[Fencommits] fenserve: interpret the function template

Tuukka Hastrup Tuukka.Hastrup at iki.fi
Sun May 20 22:43:48 EEST 2007


Sun May 20 22:42:17 EEST 2007  Tuukka Hastrup <Tuukka.Hastrup at iki.fi>
  * interpret the function template
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs	2007-05-20 22:43:47.000000000 +0300
+++ new-fenserve/fendata/Main.hs	2007-05-20 22:43:47.000000000 +0300
@@ -343,9 +343,15 @@
 addPotion :: Request -> MyState -> (String, MyState)
 addPotion msg s = ("/", s { statePotions = newPotions }) where
     Just name = lookM msg "name"
+    Just template = lookM msg "template"
     Just exp = fmap read $ lookM msg "exp"
-    potion = Fun [] [name] exp -- XXX
+    parts = f template ""
+    types = take ((length parts) - 1) $ repeat string
+    potion = Fun types parts exp
     newPotions = Map.insert name potion $ statePotions s
+    f ('$':cs) name = reverse name : f cs ""
+    f (c:cs) name = f cs (c:name)
+    f "" name = [reverse name]
 
 main = stdHTTP [ debugFilter
                , h (Prefix ["potion"]) GET $ ok $ \() -> run $ \(exp,args) s ->




More information about the Fencommits mailing list