Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 93107d4

Browse files
committed
Factor out reset.
1 parent 8539b8f commit 93107d4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

semantic-analysis/src/Analysis/Analysis/Exception.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ exceptionsForLine l e = Set.filter (\ ex -> IntSet.member l (exceptionLines ex))
106106

107107
printExcSet :: Source.Source -> ExcSet -> IO ()
108108
printExcSet src e = for_ (zip [0..] (Source.lines src)) $ \ (i, line) -> do
109-
Text.putStr (Text.pack "\ESC[37;1m" <> raise (Text.dropWhileEnd (== '\n') (Source.toText line)) <> Text.pack "\ESC[0m")
109+
Text.putStr (Text.pack "\ESC[37;1m" <> raise (Text.dropWhileEnd (== '\n') (Source.toText line)) <> reset)
110110
let es = exceptionsForLine i e
111111
fvs = freeVariablesForLine i e
112112
unless (null es && null fvs) $ do
@@ -116,11 +116,12 @@ printExcSet src e = for_ (zip [0..] (Source.lines src)) $ \ (i, line) -> do
116116
<> formatExceptions es ) <> Text.pack "}\ESC[0m")
117117
Text.putStrLn mempty
118118
where
119-
keyword k s = Text.intercalate (Text.pack "\ESC[34;1m" <> k <> Text.pack "\ESC[0m") (Text.splitOn k s)
119+
keyword k s = Text.intercalate (Text.pack "\ESC[34;1m" <> k <> reset) (Text.splitOn k s)
120120
raise = keyword (Text.pack "raise")
121121
union = Text.intercalate (Text.pack ", ")
122122
formatFreeVariables fvs = map (\ fv -> Text.pack "?" <> formatName (freeVariableName fv)) (Set.toList fvs)
123123
formatExceptions excs = map (Text.pack . show . formatName . exceptionName) (Set.toList excs)
124+
reset = Text.pack "\ESC[0m"
124125

125126
refLines :: Reference -> IntSet.IntSet
126127
refLines (Reference _ (Span (Pos startLine _) (Pos endLine _))) = IntSet.fromAscList [startLine..endLine]

0 commit comments

Comments
 (0)