
#10547: feature request: expanding type synonyms in error messages -------------------------------------+------------------------------------- Reporter: osa1 | Owner: osa1 Type: feature request | Status: new Priority: low | Milestone: 7.12.1 Component: Compiler (Type | Version: checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: D1016 -------------------------------------+------------------------------------- Comment (by simonpj): Thanks for doing this, but I think we can do better without too much difficulty. The trouble here is that * You will often display types that are identical to the ones originally reported {{{ Couldn't match type ‘Int’ with ‘Bool’ Expected type: Int Actual type: Bool Type synonyms expanded: Expected type: Int Actual type: Bool }}} That would not be helpful! * You will expand synonyms that make it more, not less obscure: {{{ Couldn't match type ‘Int’ with ‘Bool’ Expected type: T Int Actual type: T Bool Type synonyms expanded: Expected type: big -> blab -> wibble -> Int -> wottle Actual type: big -> blab -> wibble -> Bool -> wottle }}} So, what you really want to do is to walk down the two types together, expanding synonyms in the one to make it match the other, and vice versa, until you get to the actual error. A function like {{{ expandSynonymsToMatch :: Type -> Type -> (Type, Type) }}} I suppose you could return a `Maybe` to say if any expansion at all happened; or you can do a type-equality test afterwards which is perhaps easier. Make sense? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10547#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler