2015-09-20 23 views
143

我试图用ghc-mod VIM插件做类型/语法检查等。但是,我发现,ghc-mod总是使用类型完整路径的错误信息,例如:GHC-mod是否必须为类型使用全名?

test.hs|71 col 13 error| Couldn't match type ‘Data.Text.Internal.Text’                     
||    with ‘[GHC.Types.Char]’ 
|| Expected type: containers-0.5.6.2:Data.Map.Base.Map 
||     [GHC.Types.Char] 
||     ([(integer-gmp-1.0.0.0:GHC.Integer.Type.Integer, 
||      integer-gmp-1.0.0.0:GHC.Integer.Type.Integer)], 
||     containers-0.5.6.2:Data.Set.Base.Set 
||      integer-gmp-1.0.0.0:GHC.Integer.Type.Integer) 
|| Actual type: containers-0.5.6.2:Data.Map.Base.Map 
||     Data.Text.Internal.Text 
||     ([(integer-gmp-1.0.0.0:GHC.Integer.Type.Integer, 
||      integer-gmp-1.0.0.0:GHC.Integer.Type.Integer)], 
||     containers-0.5.6.2:Data.Set.Base.Set 
||      integer-gmp-1.0.0.0:GHC.Integer.Type.Integer) 
|| In the second argument of ‘containers-0.5.6.2:Data.Map.Base.map’, namely 
|| ‘zippedMap’ 
|| In the second argument of ‘(GHC.Base.$)’, namely 
|| ‘containers-0.5.6.2:Data.Map.Base.map 
... 

其中的杂波屏幕,我很难找出哪里出了问题。作为比较,这是用于使用ghci同一文件中的错误消息:

test.hs:71:13: 
    Couldn't match type ‘T.Text’ with ‘[Char]’ 
    Expected type: M.Map [Char] ([(Integer, Integer)], S.Set Integer) 
     Actual type: M.Map T.Text ([(Integer, Integer)], S.Set Integer) 
    In the second argument of ‘M.map’, namely ‘zippedMap’ 
    In the second argument of ‘($)’, namely 
     ‘M.map 
... 

这是更清洁。有没有办法让ghc-mod使用短名称的类型?

+3

这不是我观察到的行为。这是否仍然发生在你​​身上?你使用的是哪个版本的'ghc'和'ghc-mod'? – dkasak

+3

你是否有一个自包含的例子(包括进口),产生像上面那样的输出?我想我有一个想法可能是什么问题,但仅仅从输出中分辨出来有点难。 – Alec

回答

0

您可以尝试通过-dsuppress-module-prefixes作为GHC选项。在某些时候,它确实帮助我摆脱了名称中的模块限定符。

1

您可以从GHC-MOD传递参数给GHC为:

$ ghc-mod lint *.hs -g -dsuppress-module-prefixes 

这将参数-dsuppress-module-prefixes发送到GHC。

相关问题