Skip to content

re-order GHC type errors for clarity

Here's a typical simple type error from GHC:

Derive/Call/India/Pakhawaj.hs:142:62:
    Couldn't match type Text with (a1, Syllable)
    Expected type: [([(a1, Syllable)], [Sequence Bol])]
      Actual type: [([Syllable], [Sequence Bol])]
    Relevant bindings include
      syllables :: [(a1, Syllable)]
	(bound at Derive/Call/India/Pakhawaj.hs:141:16)
      best_match :: [(a1, Syllable)]
		    -> Maybe (Int, ([(a1, Syllable)], [(a1, Sequence Bol)]))
	(bound at Derive/Call/India/Pakhawaj.hs:141:5)
    In the second argument of mapMaybe, namely all_bols
    In the second argument of ($), namely
      mapMaybe (match_bols syllables) all_bols

The order of sections is "couldn't match", "expected actual", "relevant bindings", "context" (in the second argument etc.). I think it would be easier to read as "couldn't match", "expected actual", "context", "bindings", and with a * to mark each section:

Derive/Call/India/Pakhawaj.hs:142:62:
  * Couldn't match type Text with (a1, Syllable)
    Expected type: [([(a1, Syllable)], [Sequence Bol])]
      Actual type: [([Syllable], [Sequence Bol])]
  * In the second argument of mapMaybe, namely all_bols
    In the second argument of ($), namely
      mapMaybe (match_bols syllables) all_bols
  * Relevant bindings include
      syllables :: [(a1, Syllable)]
	(bound at Derive/Call/India/Pakhawaj.hs:141:16)
      best_match :: [(a1, Syllable)]
		    -> Maybe (Int, ([(a1, Syllable)], [(a1, Sequence Bol)]))
	(bound at Derive/Call/India/Pakhawaj.hs:141:5)

I'm sure there are plenty of other sections that don't show up in this simple example, in any case they should go from most to least critical and be marked off with a *.

Trac metadata
Trac field Value
Version 7.11
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information