[Fencommits] fenserve: remove existing focus()es from expressions before adding a new one

Benja Fallenstein benja.fallenstein at gmail.com
Thu Jun 21 14:33:36 EEST 2007


Thu Jun 21 14:32:38 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * remove existing focus()es from expressions before adding a new one
diff -rN -u old-fenserve/fendata/Rendering.hs new-fenserve/fendata/Rendering.hs
--- old-fenserve/fendata/Rendering.hs	2007-06-21 14:33:36.000000000 +0300
+++ new-fenserve/fendata/Rendering.hs	2007-06-21 14:33:36.000000000 +0300
@@ -60,14 +60,20 @@
                  local (\e -> e {envVars=(n var,t):envVars e}) (f var) where
     n i = (if i<26 then "" else n (i `div` 26))
        ++ [toEnum $ fromEnum 'a' + i `mod` 26]
+       
+focusPath p = focusPath' p . removeFocus
                  
-focusPath :: [Int] -> GenericT
-focusPath []     = mkT Focus
-focusPath (p:ps) = snd . f 0 where
+focusPath' :: [Int] -> GenericT
+focusPath' []     = mkT Focus
+focusPath' (p:ps) = snd . f 0 where
     f i = gfoldl k (\x -> (i,x))
     k :: Data a => (Int, a -> b) -> a -> (Int, b)
     k (i,c) x = if typeOf x /= typeOf (undefined :: Exp) then fmap c (f i x)
-                    else (i+1, c $ if i==p then focusPath ps x else x)
+                    else (i+1, c $ if i==p then focusPath' ps x else x)
+                    
+removeFocus :: GenericT
+removeFocus = gmapT removeFocus `extT` f where
+    f (Focus e) = removeFocus e; f x = gmapT removeFocus x
 
 
 data E = E Int Exp




More information about the Fencommits mailing list