- Basic usage
- Common mistakes
- Moving signatures to the top level
InstanceSigs enables explicit type signatures as part of typeclass
instance declarations.GHC documentation for
InstanceSigs This extension is safe, and it is helpful for learning and writing code incrementally. The explicit type annotations it allows may also be useful, as explicit type annotations generally are, as documentation and for readers.
The first mention of the desire for this extension we could find is in a Stack Overflow question in 2011: Why can’t one put type signatures in instance declarations in Haskell?The Stack Overflow question that led to
InstanceSigs In the answers and comments on the question, some Haskellers decided to open a ticket about this and linked to the issue. Simon Peyton-Jones commented that he had also sometimes wanted this feature and so implemented it “in a spare moment.”The Trac ticket regarding
InstanceSigs extension first appeared in GHC 7.6.1.