[Fencommits] fenserve: simplify two of the generic functions by using 'everywhere' and 'something' from the generics library
Benja Fallenstein
benja.fallenstein at gmail.com
Fri Jun 22 16:56:20 EEST 2007
Fri Jun 22 16:56:06 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* simplify two of the generic functions by using 'everywhere' and 'something' from the generics library
diff -rN -u old-fenserve/fendata/Rendering.hs new-fenserve/fendata/Rendering.hs
--- old-fenserve/fendata/Rendering.hs 2007-06-22 16:56:19.000000000 +0300
+++ new-fenserve/fendata/Rendering.hs 2007-06-22 16:56:19.000000000 +0300
@@ -59,10 +59,7 @@
++ [toEnum $ fromEnum 'a' + i `mod` 26]
getFocus :: Exp -> Maybe Exp
-getFocus exp = (case getFoci exp of (x:xs) -> Just x; [] -> Nothing) where
- getFoci :: Data a => a -> [Exp]
- getFoci = (concat . gmapQ getFoci) `extQ` expCase
- expCase (Focus e) = [e]; expCase e = concat $ gmapQ getFoci e
+getFocus = something (mkQ Nothing f) where f (Focus x) = Just x; f _ = Nothing
focusPath p = focusPath' p . removeFocus
@@ -75,8 +72,7 @@
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
+removeFocus = everywhere (mkT $ \e -> case e of Focus e' -> e'; _ -> e)
data E = E Int Exp
More information about the Fencommits
mailing list