首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >GHC-mod必须对类型使用全名吗?

GHC-mod必须对类型使用全名吗?
EN

Stack Overflow用户
提问于 2015-09-20 09:34:20
回答 2查看 1.7K关注 0票数 142

我正在尝试使用ghc-mod vim插件进行类型/语法检查等。但是,我发现ghc-mod总是在错误消息中使用类型的完整路径,例如:

代码语言:javascript
复制
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的同一文件的错误消息

代码语言:javascript
复制
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对类型使用短名称?

EN

回答 2

Stack Overflow用户

发布于 2017-09-16 01:06:55

您可以将参数从ghc-mod传递给ghc,如下所示:

代码语言:javascript
复制
$ ghc-mod lint *.hs -g -dsuppress-module-prefixes

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

票数 1
EN

Stack Overflow用户

发布于 2017-05-29 02:30:30

您可以尝试将-dsuppress-module-prefixes作为GHC选项传递。在某种程度上,它确实帮助我摆脱了名称中的模块限定符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32674883

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档