Skip to content

Allow type signatures in instance declarations

GHC should allow type signatures in instance declarations. It should check that they match the type signatures from the class, and reject with an error message if not. This has the following advantages:

  • It allows a programmer to assert what he/she thinks is the type signature of the function being defined, and have it checked against what it should be. If the programmer is wrong, this will be immediately apparent with the error message, instead of a potentially obscure type error.
  • A programmer can consistently follow the (reasonable) coding style of always writing type signatures for functions, without being hindered by "Misplaced type signature" errors and having to make a special case for instance declarations by commenting out (or removing) the type signature.
Trac metadata
Trac field Value
Version 7.2.1
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