bug or feature: generated constraints of derived Show instance
With the patch about unqualified methods in instance declarations I can compile most of my xml-basic package. However it stops at data ProcessingInstruction name string = Known [Attr.T name string] | Unknown String deriving (Eq, Ord, Show ) since the Show instance of Attr.T needs an (Name.Attribute name) constraint. JHC does not seem to generate that automatically. GHC does so, but I do not know, whether this is Haskell 98. I can fix this by writing a custom Show instance, but there are more types with that problem. The file is http://code.haskell.org/~thielema/xml-basic/src/Text/XML/Basic/ProcessingIns... and the compiler message is: Typechecking... [1 of 4] Text.XML.Basic.ProcessingInstruction(....................user error ( What: failure Why: Signature too Weak: [Jhc.Show.Show Text.XML.Basic.ProcessingInstruction.v186,Jhc.Show.Show Text.XML.Basic.ProcessingInstruction.v187] does not imply [Text.XML.Basic.Name.Attribute Text.XML.Basic.ProcessingInstruction.v186] Where: on line 11 in <unknown> in the explicitly typed Instance@.iJhc.Show.showsPrec.Text.XML.Basic.ProcessingInstruction.T Text.XML.Basic.ProcessingInstruction.73_d (Text.XML.Basic.ProcessingInstruction.Known Text.XML.Basic.ProcessingInstruction.74_aa) = Jhc.Show.showParen (Text.XML.Basic.ProcessingInstruction.73_d Jhc.Order.>= 10) (Jhc.Show.showString "Known" Jhc.Basics.. Jhc.Show.showChar ' ' Jhc.Basics.. Jhc.Show.showsPrec 10 Text.XML.Basic.ProcessingInstruction.74_aa) Instance@.iJhc.Show.showsPrec.Text.XML.Basic.ProcessingInstruction.T Text.XML.Basic.ProcessingInstruction.75_d (Text.XML.Basic.ProcessingInstruction.Unknown Text.XML.Basic.ProcessingInstruction.76_aa) = Jhc.Show.showParen (Text.XML.Basic.ProcessingInstruction.75_d Jhc.Order.>= 10) (Jhc.Show.showString "Unknown" Jhc.Basics.. Jhc.Show.showChar ' ' Jhc.Basics.. Jhc.Show.showsPrec 10 Text.XML.Basic.ProcessingInstruction.76_aa) {- on line 11 -} Compilation of module: Text.XML.Basic.ProcessingInstruction)
On Sat, Nov 14, 2009 at 07:05:00PM +0100, Henning Thielemann wrote:
With the patch about unqualified methods in instance declarations I can compile most of my xml-basic package. However it stops at
data ProcessingInstruction name string = Known [Attr.T name string] | Unknown String deriving (Eq, Ord, Show )
since the Show instance of Attr.T needs an (Name.Attribute name) constraint. JHC does not seem to generate that automatically. GHC does so, but I do not know, whether this is Haskell 98. I can fix this by writing a custom Show instance, but there are more types with that problem.
Probably a bug, otherwise data T a = T [a] deriving (Show) wouldn't work because instance Show a => Show [a] where ... -- Felipe.
participants (2)
-
Felipe Lessa -
Henning Thielemann