[GHC] #8809: Prettier error messages?

GHC ghc-devs at haskell.org
Thu Nov 17 06:40:32 UTC 2016


#8809: Prettier error messages?
-------------------------------------+-------------------------------------
        Reporter:  joelteon          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
  #8809,#10073,#10179                |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Phyx-):

 Yeah, you might still be required to manually turn on
 `ENABLE_VIRTUAL_TERMINAL_PROCESSING` and possibly
 `DISABLE_NEWLINE_AUTO_RETURN` If you get into modifying GHCi to have fancy
 stuff too.

 That build is still significant since it's the one that brought native
 support in `conhost` for VT100 escape sequences. But yeah checking the
 flag on the buffer is what should be done, but because there's a large
 number of people using `ANSICON` we should check that too. VT100 support
 used to be only in the dos driver `ansi.sys` which is what is deprecated.
 You couldn't use it in Windows but the docs all referred to it.

 But I'm happy to hear you plan on some Windows love too :). I wouldn't
 bother going down the road of `SetConsoleTextAttribute`. Unless we want to
 support the Pre Windows 10 era for this. That said, the design in
 comment:9 is the perfect way to make this easy to do. You just have a
 custom renderer then that interprets the `Doc`.

 Yeah the patch will add `GetConsoleMode` and `SetConsoleMode`, but while
 they'll be usable for user program, the bootstrap process of GHC doesn't
 allow you to use libraries not available on the bootstrapping compiler. So
 you'd have to duplicate the code to inside GHC until a few releases down
 the road where we can undo the duplication.

 You'll end up with something like:

 {{{
 isVT100ConsoleSupported :: IO Bool
 isVT100ConsoleSupported
  = do isANSIcon <- fmap (maybe False ((/=""     ) . map toLower)) $
 lookupEnv "ANSICON"
       isConEmu  <- fmap (maybe False ((=="on"   ) . map toLower)) $
 lookupEnv "ConEmuANSI"
       isTerm    <- fmap (maybe False ((=="xterm") . map toLower)) $
 lookupEnv "TERM"
       hOut <- getStdHandle sTD_OUTPUT_HANDLE
       outMode <- with 64 $ \ c_mask -> do
          failIfFalse_ "GetConsoleMode" $ c_GetConsoleMode hOut c_mask
          peek c_mask
       return $ or [ isANSIcon
                   , isConEmu
                   , isTerm
                   , let flag = outMode .&.
 eNABLE_VIRTUAL_TERMINAL_PROCESSING
                     in flag == eNABLE_VIRTUAL_TERMINAL_PROCESSING
                   ]
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8809#comment:34>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list