Skip to content

Commit

Permalink
Add option to hide prelude from certain step
Browse files Browse the repository at this point in the history
  • Loading branch information
edsko committed Dec 20, 2023
1 parent 966c0fb commit 4227a04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/CBN/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ parseSummarizeOptions = SummarizeOptions
, value 1000
, metavar "N"
])
<*> (switch $ mconcat [
<*> (optional $ option auto $ mconcat [
long "hide-prelude"
, help "Hide the prelude from the help"
, metavar "STEP"
, help "Hide the prelude from the help from the given step"
])
<*> (many $ option str $ mconcat [
long "hide-term"
Expand Down
12 changes: 7 additions & 5 deletions src/CBN/Trace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ traceTerm shouldGC shouldInline enableSelThunkOpt = go
data SummarizeOptions = SummarizeOptions {
summarizeCollapseBeta :: Bool
, summarizeMaxNumSteps :: Int
, summarizeHidePrelude :: Bool
, summarizeHidePrelude :: Maybe Int
, summarizeHideTerms :: [String]
, summarizeHideGC :: Bool
, summarizeHideSelThunk :: Bool
Expand Down Expand Up @@ -167,7 +167,7 @@ summarize SummarizeOptions{..} = go 0

where
showSrc :: TraceCont -> Trace
showSrc = Trace (goHeap hp, e)
showSrc = Trace (goHeap n hp, e)

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

-- | Cleanup the heap
goHeap :: Heap Term -> Heap Term
goHeap (Heap next heap) =
goHeap :: Int -> Heap Term -> Heap Term
goHeap n (Heap next heap) =
Heap next $ Map.filterWithKey shouldShow heap
where
shouldShow :: Ptr -> Term -> Bool
shouldShow (Ptr Nothing (Just name)) _ = and [
not summarizeHidePrelude
case summarizeHidePrelude of
Nothing -> True
Just n' -> n < n'
, not (name `elem` summarizeHideTerms)
]
shouldShow (Ptr _ _) _ = True
Expand Down

0 comments on commit 4227a04

Please sign in to comment.