Is it possible to invert the order errors are displayed?

谁说胖子不能爱 提交于 2019-12-08 14:33:55

问题


When compiling a faulty program with GHC, errors are displayed in ascending line order. That causes the first errors to get pushed up the console, so you need to scroll up if you work by fixing the first errors first, which may be annoying. Is it possible to ask GHC to print errors in descending line order?


回答1:


You can do this with the -freverse-errors option flag of the GHC compiler. So you should compile it with:

ghc -freverse-errors code.hs

Like the documentation says:

-freverse-errors

Display errors in GHC/GHCi sorted by reverse order of source code line numbers.

Since this option is dynamic, you can set this option per file. So you can add the following to files for which you want to enable this:

{-# OPTIONS_GHC -freverse-errors #-}

Since this is - to the best of my knowledge - a GHC specific flag, it will probably not work for other compilers (and of course older versions of the GHC compiler).



来源:https://stackoverflow.com/questions/51287431/is-it-possible-to-invert-the-order-errors-are-displayed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!