Does GHC-mod have to use full names for types?
Asked Answered
P

2

141

I'm trying to use the ghc-mod vim plugin to do type/syntax checking etc. However, I found that ghc-mod always uses full paths of types in the error messages, for example:

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

which clutters the screen and it's very hard for me to find out where went wrong. As comparison, this is the error message for the same file using 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
...

which is much cleaner. Is there a way to make ghc-mod use short names for the types?

Puttyroot answered 20/9, 2015 at 1:34 Comment(2)
This isn't the observed behaviour for me. Is this still happening for you? Which versions of ghc and ghc-mod are you using?Engud
Do you have a self contained example (imports included) that generates output like the above? I think I have an idea what the problem might be, but it is a bit hard to tell only from the output...Earmark
D
1

You can pass the argument to ghc from ghc-mod as:

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

This will send the argument -dsuppress-module-prefixes to ghc.

Depth answered 15/9, 2017 at 17:6 Comment(0)
H
0

You can try passing -dsuppress-module-prefixes as a GHC option. At some point, it did help me to get rid of module qualifiers in names.

Halogenate answered 28/5, 2017 at 18:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.