[clean up VMap code, treat placeholders differently. limit recursive depth of VMap.
John Meacham <john@repetae.net>**20060226044258] hunk ./Fixer/VMap.hs 30
-    vmapNodes   :: Set.Set (Either (Proxy p) n)
+    vmapNodes   :: Either (Proxy p) (Set.Set n)
hunk ./Fixer/VMap.hs 34
--- A placeholder is either a placeholder, or an indirection of a placeholder.
-data Proxy p = Proxy p | ProxyArg (Proxy p) Int
+data Proxy p = Proxy p | DepthExceeded
hunk ./Fixer/VMap.hs 39
-    showsPrec n (ProxyArg p i) = showsPrec n p .  (('-':show i) ++)
+    showsPrec n DepthExceeded = ('*':)
hunk ./Fixer/VMap.hs 42
-emptyVMap = VMap { vmapArgs = mempty, vmapNodes = mempty }
+emptyVMap = VMap { vmapArgs = mempty, vmapNodes = Right mempty }
hunk ./Fixer/VMap.hs 44
-vmapSingleton n = emptyVMap { vmapNodes = Set.singleton (Right n) }
+vmapSingleton n = emptyVMap { vmapNodes = Right $ Set.singleton n }
hunk ./Fixer/VMap.hs 48
-    | otherwise = emptyVMap { vmapArgs = Map.singleton (n,i) v }
+    | otherwise = pruneVMap $ emptyVMap { vmapArgs = Map.singleton (n,i) v }
hunk ./Fixer/VMap.hs 55
-vmapProxyIndirect i vm = emptyVMap {  vmapNodes = Set.fromList [  Left p {- (ProxyArg p i) -} | Left p <- Set.toList $ vmapNodes vm] }
+vmapProxyIndirect _ VMap { vmapNodes = Left l } = emptyVMap { vmapNodes = Left l }
+vmapProxyIndirect _ _ = emptyVMap
hunk ./Fixer/VMap.hs 59
-vmapValue n xs = pruneVMap VMap { vmapArgs = Map.fromAscList (zip (zip (repeat n) [0..]) xs), vmapNodes = Set.singleton (Right n) }
+vmapValue n xs = pruneVMap VMap { vmapArgs = Map.fromAscList (zip (zip (repeat n) [0..]) xs), vmapNodes = Right $ Set.singleton n }
hunk ./Fixer/VMap.hs 62
-vmapPlaceholder p = emptyVMap { vmapNodes = Set.singleton $ Left (Proxy p) }
+vmapPlaceholder p = emptyVMap { vmapNodes = Left (Proxy p) }
hunk ./Fixer/VMap.hs 66
-vmapHeads VMap { vmapNodes = set }
-    | any isLeft (Set.toList set) = fail "vmapHeads: VMap has a placeholder"
-    | otherwise = return $ rights $ Set.toList set
-vmapMember n VMap { vmapNodes = set } = Right n `Set.member` set || any isLeft (Set.toList set)
+vmapHeads VMap { vmapNodes = Left _ } = fail "vmapHeads: VMap is unknown"
+vmapHeads VMap { vmapNodes = Right set } = return $ Set.toList set
hunk ./Fixer/VMap.hs 69
+vmapMember n VMap { vmapNodes = Left _ } = True
+vmapMember n VMap { vmapNodes = Right set } = n `Set.member` set
hunk ./Fixer/VMap.hs 72
-pruneVMap VMap { vmapArgs = map, vmapNodes =  set} = VMap {vmapArgs = map', vmapNodes = set} where
-    map' = Map.filter f map
-    f vs = not $ isBottom vs
+
+pruneVMap vmap = f (7::Int) vmap where
+    f 0 _ = emptyVMap { vmapNodes = Left DepthExceeded }
+    f _ VMap { vmapNodes = Left p} = emptyVMap {vmapNodes = Left p}
+    f n VMap { vmapArgs = map, vmapNodes =  set} = VMap {vmapArgs = map', vmapNodes = set} where
+        map' = Map.filter g (Map.map (f (n - 1)) map)
+        g vs = not $ isBottom vs
hunk ./Fixer/VMap.hs 81
-    showsPrec _ VMap { vmapArgs = n, vmapNodes = s } = braces (hcat (intersperse (char ',') $ (map f $ snub $ (map Right $ fsts $ Map.keys n) ++ Set.toList s) )) where
+    showsPrec n VMap { vmapNodes = Left p } = showsPrec n p
+    showsPrec _ VMap { vmapArgs = n, vmapNodes = Right s } = braces (hcat (intersperse (char ',') $ (map f $ snub $ (fsts $ Map.keys n) ++ Set.toList s) )) where
hunk ./Fixer/VMap.hs 84
-        g a = sortUnder fst [ (i,v) | ((a',i),v) <- Map.toList n, Right a' == a ]
+        g a = sortUnder fst [ (i,v) | ((a',i),v) <- Map.toList n, a' == a ]
hunk ./Fixer/VMap.hs 88
-    isBottom VMap { vmapArgs = m, vmapNodes = s } = Map.null m && Set.null s
-    lub VMap { vmapArgs = as, vmapNodes = ns } VMap { vmapArgs = as', vmapNodes = ns'} = pruneVMap $ VMap {vmapArgs = Map.unionWith lub as as', vmapNodes = Set.union ns ns' }
-    minus VMap { vmapArgs = n1, vmapNodes = w1} VMap { vmapArgs = n2, vmapNodes = w2 } = pruneVMap $ VMap { vmapArgs = Map.fromAscList $ [
+    isBottom VMap { vmapArgs = m, vmapNodes = Right s } = Map.null m && Set.null s
+    isBottom _ = False
+    lub x y | x `lte` y = y
+    lub x y | y `lte` x = x
+    lub VMap { vmapNodes = Left p } _ = emptyVMap { vmapNodes = Left p }
+    lub _ VMap { vmapNodes = Left p } = emptyVMap { vmapNodes = Left p }
+    lub VMap { vmapArgs = as, vmapNodes = Right ns } VMap { vmapArgs = as', vmapNodes = Right ns'} = pruneVMap $ VMap {vmapArgs = Map.unionWith lub as as', vmapNodes = Right $ Set.union ns ns' }
+    minus _ VMap { vmapNodes = Left _ } = bottom
+    minus x@VMap { vmapNodes = Left _ } _ = x
+    minus VMap { vmapArgs = n1, vmapNodes = Right w1} VMap { vmapArgs = n2, vmapNodes = Right w2 } = pruneVMap $ VMap { vmapArgs = Map.fromAscList $ [
hunk ./Fixer/VMap.hs 101
-        | ((a,i),v) <- Map.toAscList n1 ], vmapNodes = (w1 Set.\\ w2) }
-    lte x@VMap { vmapArgs = as, vmapNodes = ns } y@VMap { vmapArgs = as', vmapNodes = ns'} = any isLeft (Set.toList ns') || isBottom (x `minus` y)
+        | ((a,i),v) <- Map.toAscList n1 ], vmapNodes = Right (w1 Set.\\ w2) }
+    lte _ VMap { vmapNodes = Left _ } = True
+    lte VMap { vmapNodes = Left _ } _ = False
+    lte x@VMap { vmapArgs = as, vmapNodes = Right ns } y@VMap { vmapArgs = as', vmapNodes = Right ns'} =  (Set.null (ns Set.\\ ns') && (Map.null $ Map.differenceWith (\a b -> if a `lte` b then Nothing else Just undefined) as as'))