
If you remove the constraint from duplicateDecl, then I get
Redundant constraint: SYB.Data t
In the type signature for:
definingSigsNames :: SYB.Data t =>
[GHC.Name] -> t -> [GHC.LSig GHC.Name]
which is 100% correct: defininingSigssNames doesn’t use its SYB.Data t constraint
Simon
From: Alan & Kim Zimmerman [mailto:alan.zimm@gmail.com]
Sent: 09 January 2015 11:22
To: Simon Peyton Jones
Cc: ghc-devs@haskell.org
Subject: Re: warn-redundant-constraints present as errors
Thanks.
I've found a case where it warns of a redundant constraint, but if I remove the constraint I get an error saying the constraint is required
--------------------------------------------
import qualified GHC as GHC
import qualified Data.Generics as SYB
duplicateDecl :: (SYB.Data t) => -- **** The constraint being warned against *******
[GHC.LHsBind GHC.Name] -- ^ The declaration list
->t -- ^ Any signatures are in here
->GHC.Name -- ^ The identifier whose definition is to be duplicated
->GHC.Name -- ^ The new name (possibly qualified)
->IO [GHC.LHsBind GHC.Name] -- ^ The result
duplicateDecl decls sigs n newFunName
= do
let sspan = undefined
newSpan <- case typeSig of
[] -> return sspan
_ -> do
let Just sspanSig = getSrcSpan typeSig
toksSig <- getToksForSpan sspanSig
let [(GHC.L sspanSig' _)] = typeSig
return sspanSig'
undefined
where
typeSig = definingSigsNames [n] sigs
-- |Find those type signatures for the specified GHC.Names.
definingSigsNames :: (SYB.Data t) =>
[GHC.Name] -- ^ The specified identifiers.
->t -- ^ A collection of declarations.
->[GHC.LSig GHC.Name] -- ^ The result.
definingSigsNames pns ds = def ds
where def = undefined
getSrcSpan = undefined
getToksForSpan = undefined
--------------------------------------------
On Fri, Jan 9, 2015 at 1:08 PM, Simon Peyton Jones