@@ -59,6 +59,9 @@ newtype Frame = Frame
5959
6060type Heap = IntMap. IntMap Concrete
6161
62+ data Edge = Lexical | Import
63+ deriving (Eq , Ord , Show )
64+
6265
6366-- | Concrete evaluation of a term to a value.
6467--
@@ -153,14 +156,14 @@ runHeap = runState mempty
153156-- > λ let (heap, res) = concrete [ruby]
154157-- > λ writeFile "/Users/rob/Desktop/heap.dot" (export (addressStyle heap) (heapAddressGraph heap))
155158-- > λ :!dot -Tsvg < ~/Desktop/heap.dot > ~/Desktop/heap.svg
156- heapGraph :: (Precise -> Concrete -> a ) -> (Either Core. Edge User -> Precise -> G. Graph a ) -> Heap -> G. Graph a
159+ heapGraph :: (Precise -> Concrete -> a ) -> (Either Edge User -> Precise -> G. Graph a ) -> Heap -> G. Graph a
157160heapGraph vertex edge h = foldr (uncurry graph) G. empty (IntMap. toList h)
158161 where graph k v rest = (G. vertex (vertex k v) `G.connect` outgoing v) `G.overlay` rest
159162 outgoing = \ case
160163 Unit -> G. empty
161164 Bool _ -> G. empty
162165 String _ -> G. empty
163- Closure _ _ _ env -> foldr (G. overlay . edge (Left Core. Lexical )) G. empty env
166+ Closure _ _ _ env -> foldr (G. overlay . edge (Left Lexical )) G. empty env
164167 Record frame -> foldr (G. overlay . uncurry (edge . Right )) G. empty (Map. toList frame)
165168
166169heapValueGraph :: Heap -> G. Graph Concrete
@@ -173,10 +176,10 @@ heapAddressGraph = heapGraph (\ addr v -> (Value v, addr)) (fmap G.vertex . (,)
173176addressStyle :: Heap -> G. Style (EdgeType , Precise ) Text
174177addressStyle heap = (G. defaultStyle vertex) { G. edgeAttributes }
175178 where vertex (_, addr) = pack (show addr) <> " = " <> maybe " ?" fromConcrete (IntMap. lookup addr heap)
176- edgeAttributes _ (Slot name, _) = [" label" G. := name]
177- edgeAttributes _ (Edge Core. Import , _) = [" color" G. := " blue" ]
178- edgeAttributes _ (Edge Core. Lexical , _) = [" color" G. := " green" ]
179- edgeAttributes _ _ = []
179+ edgeAttributes _ (Slot name, _) = [" label" G. := name]
180+ edgeAttributes _ (Edge Import , _) = [" color" G. := " blue" ]
181+ edgeAttributes _ (Edge Lexical , _) = [" color" G. := " green" ]
182+ edgeAttributes _ _ = []
180183 fromConcrete = \ case
181184 Unit -> " ()"
182185 Bool b -> pack $ show b
@@ -186,7 +189,7 @@ addressStyle heap = (G.defaultStyle vertex) { G.edgeAttributes }
186189 showPos (Pos l c) = pack (show l) <> " :" <> pack (show c)
187190
188191data EdgeType
189- = Edge Core. Edge
192+ = Edge Edge
190193 | Slot User
191194 | Value Concrete
192195 deriving (Eq , Ord , Show )
0 commit comments