diff --git a/.gitignore b/.gitignore index fdf5d3c..ef7fc1c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist-newstyle/ .cabal-sandbox .stack-work .cabal.sandbox.config +.envrc diff --git a/examples/open_rec_version0.hs b/examples/open_rec_version0.hs new file mode 100644 index 0000000..bd8d828 --- /dev/null +++ b/examples/open_rec_version0.hs @@ -0,0 +1,15 @@ +object = (\f -> f (@object f)) + +mkCounter = (\this -> \n -> + Counter (this (add 1 n)) n + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +main = @value (@tick (@tick (@object @mkCounter 0))) diff --git a/examples/open_rec_version1.hs b/examples/open_rec_version1.hs new file mode 100644 index 0000000..f1c63cc --- /dev/null +++ b/examples/open_rec_version1.hs @@ -0,0 +1,20 @@ +object = (\f -> f (@object f)) + +mkCounter = (\this -> \n -> + Counter (this (add 1 n)) n + ) + +faster = (\this -> \n -> + let c = @mkCounter this n + in Counter (this (add 2 n)) (@value c) + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +main = @value (@tick (@tick (@object @faster 0))) diff --git a/examples/open_rec_version2.hs b/examples/open_rec_version2.hs new file mode 100644 index 0000000..2bb1746 --- /dev/null +++ b/examples/open_rec_version2.hs @@ -0,0 +1,24 @@ +object = (\f -> f undefined (@object f)) + +mkCounter = (\super -> \this -> \n -> + Counter (this (add 1 n)) n + ) + +faster = (\super -> \this -> \n -> + let c = super n + in Counter (this (add 2 n)) (@value c) + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +mixin = (\f -> \g -> \super -> \this -> + f (g super this) this + ) + +main = @value (@tick (@tick (@object (@mixin @faster @mkCounter) 0))) diff --git a/minimal.html b/minimal.html index 7331ede..05af18d 100644 --- a/minimal.html +++ b/minimal.html @@ -9,7 +9,6 @@ -
Term
Heap
Graph
diff --git a/src/CBN/Options.hs b/src/CBN/Options.hs index 8be41a4..465106d 100644 --- a/src/CBN/Options.hs +++ b/src/CBN/Options.hs @@ -77,6 +77,10 @@ parseSummarizeOptions = SummarizeOptions long "hide-prelude" , help "Hide the prelude from the help" ]) + <*> (many $ option str $ mconcat [ + long "hide-term" + , help "Hide specific term from the prelude (can be used multiple times)" + ]) <*> (switch $ mconcat [ long "hide-gc" , help "Hide GC steps" diff --git a/src/CBN/Trace.hs b/src/CBN/Trace.hs index 4619941..dc9e5f3 100644 --- a/src/CBN/Trace.hs +++ b/src/CBN/Trace.hs @@ -66,6 +66,7 @@ data SummarizeOptions = SummarizeOptions { summarizeCollapseBeta :: Bool , summarizeMaxNumSteps :: Int , summarizeHidePrelude :: Bool + , summarizeHideTerms :: [String] , summarizeHideGC :: Bool } deriving (Show) @@ -103,12 +104,12 @@ summarize SummarizeOptions{..} = go 0 -- | Cleanup the heap goHeap :: Heap Term -> Heap Term - goHeap (Heap next heap) = Heap next $ - if not summarizeHidePrelude - then heap - else Map.filterWithKey (\ptr -> not . isPrelude ptr) heap - - -- | Does this entry in the heap come from the prelude? - isPrelude :: Ptr -> Term -> Bool - isPrelude (Ptr Nothing (Just _)) _ = True - isPrelude _ _ = False + goHeap (Heap next heap) = + Heap next $ Map.filterWithKey shouldShow heap + where + shouldShow :: Ptr -> Term -> Bool + shouldShow (Ptr Nothing (Just name)) _ = and [ + not summarizeHidePrelude + , not (name `elem` summarizeHideTerms) + ] + shouldShow (Ptr _ _) _ = True