Trex-generated Show instances dodgy

Anthony Clayden anthony.d.clayden at gmail.com
Fri Aug 26 02:04:36 UTC 2022


Strange: on loading this module, Hugs complains (this is standard-issue Sep
2006 Hugs in Hugsmode)

> - An instance of ShowRecRow (x :: a, y :: a) is required to derive Show
(NPoint a)

Just loading it again and the complaint disappears.

> module NPoint  where
>
>     import Hugs.Trex
>
>     newtype Num a => NPoint a  = MkNPoint ( Rec( x :: a, y :: a))
 deriving (Eq, Show)
>

If I ask for :info ShowRecRow after the failed load, I see an instance each
for label x, y -- as well as the EmptyRow instance (standard with
Hugs.Trex). If I :load Hugs.Trex after the failed load, those two instances
have gone; I can load NPoint ok.

On firing up Hugs, if I :load Hugs.Trex before :load NPoint, the error
still happens. But if I

>print (z = 5)                                -- some arbitrary label

then :load NPrint, all is fine. (And there's no ghost ShowRecRow instance
for z.)

If I 'clear modules' after the failed load; then :load NPoint, no error.

Same for an ordinary data decl wrapping a Trex record, with deriving. Same
if I include some arbitrary `silly = show (silly = "shilly")`.

AntC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/hugs-bugs/attachments/20220826/e36e6797/attachment.html>


More information about the Hugs-Bugs mailing list