【问题标题】:Does GHC-mod have to use full names for types?GHC-mod 是否必须使用类型的全名?
【发布时间】:2015-12-16 22:51:51
【问题描述】:

我正在尝试使用ghc-mod vim 插件进行类型/语法检查等。但是,我发现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 使用类型的短名称?

【问题讨论】:

  • 这不是我观察到的行为。这仍然发生在你​​身上吗?您使用的是ghcghc-mod 的哪个版本?
  • 您是否有一个自包含示例(包括导入),可以生成类似上述的输出?我想我知道问题可能是什么,但是仅从输出中很难判断...

标签: haskell ghc ghc-mod


【解决方案1】:

您可以将参数从 ghc-mod 传递给 ghc:

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多