Skip to content

Missing context in Generics example

The Haddocks for GHC.Generics give an example of a default implementation using Generics:

class Encode a where
  encode :: a -> [Bool]
  default encode :: (Generic a) => a -> [Bool]
  encode x = encode' (from x)

The default signature is missing some context. It should read

  default encode :: (Generic a, Encode' (Rep a)) => a -> [Bool]
Trac metadata
Trac field Value
Version 7.10.3
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Core Libraries
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ekmett
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information