Skip to content

Commit 95b2fd6

Browse files
committed
Add option to hide prelude from certain step
1 parent 966c0fb commit 95b2fd6

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

examples/circular_hos.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
--
99
-- > cabal run visualize-cbn -- \
1010
-- > --show-trace \
11-
-- > --hide-prelude \
11+
-- > --hide-prelude=1 \
1212
-- > --gc \
1313
-- > --selector-thunk-opt \
1414
-- > --inline-heap \

examples/repmin.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--
66
-- > cabal run visualize-cbn -- \
77
-- > --show-trace \
8-
-- > --hide-prelude \
8+
-- > --hide-prelude=1 \
99
-- > --gc \
1010
-- > --selector-thunk-opt \
1111
-- > --inline-heap \

src/CBN/Options.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ parseSummarizeOptions = SummarizeOptions
8888
, value 1000
8989
, metavar "N"
9090
])
91-
<*> (switch $ mconcat [
91+
<*> (optional $ option auto $ mconcat [
9292
long "hide-prelude"
93-
, help "Hide the prelude from the help"
93+
, metavar "STEP"
94+
, help "Hide the prelude from the help from the given step"
9495
])
9596
<*> (many $ option str $ mconcat [
9697
long "hide-term"

src/CBN/Trace.hs

+7-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ traceTerm shouldGC shouldInline enableSelThunkOpt = go
102102
data SummarizeOptions = SummarizeOptions {
103103
summarizeCollapseBeta :: Bool
104104
, summarizeMaxNumSteps :: Int
105-
, summarizeHidePrelude :: Bool
105+
, summarizeHidePrelude :: Maybe Int
106106
, summarizeHideTerms :: [String]
107107
, summarizeHideGC :: Bool
108108
, summarizeHideSelThunk :: Bool
@@ -167,7 +167,7 @@ summarize SummarizeOptions{..} = go 0
167167

168168
where
169169
showSrc :: TraceCont -> Trace
170-
showSrc = Trace (goHeap hp, e)
170+
showSrc = Trace (goHeap n hp, e)
171171

172172
-- | We already saw one beta reduction; skip any subsequent ones
173173
goBeta :: Int -> Trace -> TraceCont
@@ -186,13 +186,15 @@ summarize SummarizeOptions{..} = go 0
186186
_otherwise -> False
187187

188188
-- | Cleanup the heap
189-
goHeap :: Heap Term -> Heap Term
190-
goHeap (Heap next heap) =
189+
goHeap :: Int -> Heap Term -> Heap Term
190+
goHeap n (Heap next heap) =
191191
Heap next $ Map.filterWithKey shouldShow heap
192192
where
193193
shouldShow :: Ptr -> Term -> Bool
194194
shouldShow (Ptr Nothing (Just name)) _ = and [
195-
not summarizeHidePrelude
195+
case summarizeHidePrelude of
196+
Nothing -> True
197+
Just n' -> n < n'
196198
, not (name `elem` summarizeHideTerms)
197199
]
198200
shouldShow (Ptr _ _) _ = True

0 commit comments

Comments
 (0)