Documentation of class declarations in hs-boot files is wrong
Summary
Location of documentation issue: the GHC user's guide section on filenames and separate compilation.
The documentation states that in .hs-boot
files,
Class declarations is exactly as in Haskell, except that you may not put default method declarations. You can also omit all the superclasses and class methods entirely; but you must either omit them all or put them all in.
Regarding default method definitions, this is the opposite of reality: compilation will actually fail if the .hs-boot
file is missing default method definitions present in the corresponding .hs
file!
Proposed improvements or changes
The easy fix is to update the documentation to reflect reality. The alternative would be to allow some default method definitions to be omitted; in that case, instances found in modules importing the class definition using a {-# SOURCE #-}
import would need to define more methods to be complete.
Environment
- GHC version used (if appropriate): 9.0