是否可以反转显示的订单错误? [英] Is it possible to invert the order errors are displayed?

查看:64
本文介绍了是否可以反转显示的订单错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用GHC编译有故障的程序时,错误以升序显示.这会导致第一个错误被调高到控制台,因此,如果您要先解决第一个错误,则需要向上滚动,这可能会很烦人.是否可以要求GHC按降序打印错误?

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?

推荐答案

您可以使用GHC编译器的 -freverse-errors 选项标志来执行此操作.因此,您应该使用以下代码进行编译:

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

类似于文档说:

-freverse-errors

GHC/GHCi中的显示错误按源代码行号的反向顺序排序.

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 #-}

据我所知,因为这是一个GHC特定标志,所以它可能对其他编译器(当然也包括较旧版本的GHC编译器)不起作用.

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).

这篇关于是否可以反转显示的订单错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆