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

HaskellGhcGhc Mod

Haskell Problem Overview


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?

Haskell Solutions


Solution 1 - Haskell

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.

Solution 2 - Haskell

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionxzhuView Question on Stackoverflow
Solution 1 - HaskellKronosView Answer on Stackoverflow
Solution 2 - HaskellsergvView Answer on Stackoverflow