StandaloneDeriving and DeriveAnyClass don't work together
I'm starting with the SPretty
example from the DeriveAnyClass
section in the GHC users guide:
#!/usr/bin/env stack
-- stack --resolver lts-8.0
{-# LANGUAGE DefaultSignatures, DeriveAnyClass, StandaloneDeriving #-}
import Prelude
import Numeric.Natural (Natural)
class SPretty a where
sPpr :: a -> String
default sPpr :: Show a => a -> String
sPpr = show
I can write an empty instance for Natural
:
instance SPretty Natural where
So then I would expect to be able to write an equivalent definition using StandaloneDeriving
and DeriveAnyClass
:
deriving instance SPretty Natural
But instead it fails with this error:
error:
• Can't make a derived instance of ‘SPretty Natural’:
The data constructors of ‘Natural’ are not all in scope
so you cannot derive an instance for it
• In the stand-alone deriving instance for ‘SPretty Natural’
It seems like this ought to work; I'm not sure why the constructors should need to be in scope, given that the instance can be derived trivially without defining any methods.