mirror of
https://github.com/Mesabloo/diagnose.git
synced 2024-11-22 17:52:15 +03:00
diagnostic: do not even try to display something on empty diagnostic
This commit is contained in:
parent
9604a8a695
commit
5b96ec360b
@ -31,6 +31,11 @@ Diagnostic files reports <++> report = Diagnostic files (reports ++ [report])
|
|||||||
infixl 5 <++>
|
infixl 5 <++>
|
||||||
infixl 4 <~<
|
infixl 4 <~<
|
||||||
|
|
||||||
|
-- | Checks whether a 'Diagnostic' is empty or not, i.e. it has no reports.
|
||||||
|
empty :: Diagnostic s m a -> Bool
|
||||||
|
empty (Diagnostic _ []) = True
|
||||||
|
empty _ = False
|
||||||
|
|
||||||
|
|
||||||
instance (Foldable s, PrettyText (s a), PrettyText m) => PrettyText (Diagnostic s m a) where
|
instance (Foldable s, PrettyText (s a), PrettyText m) => PrettyText (Diagnostic s m a) where
|
||||||
prettyText (Diagnostic _ []) = empty
|
prettyText (Diagnostic _ []) = empty
|
||||||
@ -39,4 +44,6 @@ instance (Foldable s, PrettyText (s a), PrettyText m) => PrettyText (Diagnostic
|
|||||||
|
|
||||||
-- | Prints a @'Diagnostic' s m a@ To the given @'Handle'@
|
-- | Prints a @'Diagnostic' s m a@ To the given @'Handle'@
|
||||||
printDiagnostic :: (Foldable s, PrettyText (s a), PrettyText m) => Bool -> Handle -> Diagnostic s m a -> IO ()
|
printDiagnostic :: (Foldable s, PrettyText (s a), PrettyText m) => Bool -> Handle -> Diagnostic s m a -> IO ()
|
||||||
printDiagnostic withColor handle diag = displayIO handle (renderPretty 0.9 80 . (if withColor then id else plain) $ prettyText diag)
|
printDiagnostic withColor handle diag
|
||||||
|
| empty diag = pure ()
|
||||||
|
| otherwise = displayIO handle (renderPretty 0.9 80 . (if withColor then id else plain) $ prettyText diag)
|
||||||
|
Loading…
Reference in New Issue
Block a user