[jhc] bug or feature: generated constraints of derived Show instance

Henning Thielemann jhc at henning-thielemann.de
Sat Nov 14 13:05:00 EST 2009


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/ProcessingInstruction.hs

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 at .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 at .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)



More information about the jhc mailing list