diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2011-09-29 09:45:42 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2011-09-29 09:45:42 +0100 |
commit | ba60fc61ba5bbac8d0bbeb719fe26daa4058e1c5 (patch) | |
tree | 954b8e6e7cd92ab8f5213004e725ee5a6fbf1ac3 /compiler/utils | |
parent | 962195913a0262b3300332ee0eee02f1bb2125a2 (diff) | |
download | haskell-ba60fc61ba5bbac8d0bbeb719fe26daa4058e1c5.tar.gz |
Make Outputable.quotes do what the comments say
Outputable.quotes claimed to drop the quotes if the enclosed thing has
a trailing single quote; but its implementation checked for
a *leading* quote.
Fixes Trac #5509
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Outputable.lhs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs index 833309e6aa..136a1a2151 100644 --- a/compiler/utils/Outputable.lhs +++ b/compiler/utils/Outputable.lhs @@ -77,6 +77,7 @@ import FastString import FastTypes import Platform import qualified Pretty +import Util ( snocView ) import Pretty ( Doc, Mode(..) ) import Panic @@ -451,14 +452,14 @@ cparen :: Bool -> SDoc -> SDoc cparen b d = SDoc $ Pretty.cparen b . runSDoc d --- quotes encloses something in single quotes... +-- 'quotes' encloses something in single quotes... -- but it omits them if the thing ends in a single quote -- so that we don't get `foo''. Instead we just have foo'. quotes d = SDoc $ \sty -> let pp_d = runSDoc d sty in - case show pp_d of - ('\'' : _) -> pp_d - _other -> Pretty.quotes pp_d + case snocView (show pp_d) of + Just (_, '\'') -> pp_d + _other -> Pretty.quotes pp_d semi, comma, colon, equals, space, dcolon, arrow, underscore, dot :: SDoc darrow, lparen, rparen, lbrack, rbrack, lbrace, rbrace, blankLine :: SDoc |