-- In the context of this program Hugs 1.4 prints
-- the expressions
-- Pz
-- tolist Pz
-- as an error (can't find show function) and []
-- respectively. I asked Phil Wadler about it.
-- He was surprised, but referred me to higher
-- authority. Is the behavior correct?
-- If so, why?
-- Thanks,
-- Doug McIlroy
data Num a => Ps a = Pz
tolist:: Num a => Ps a -> [a]
tolist Pz = []
instance Num a => Show (Ps a) where
showsPrec p f = showsPrec p (tolist f)
-- P.S. As an example of operator overloading for
-- possible inclusion in your web site's bibliography,
-- I offer this link to my functional pearl, "Power
-- series, power serious", JFP 9 (1999) 323-335
-- http://www.cs.dartmouth.edu/~doug/pearl.ps.gz