Inconsistent strictness of Data.Generics.toConstr
Nils Anders Danielsson
nad at cs.chalmers.se
Thu Jun 2 10:42:40 EDT 2005
Data.Generics.toConstr is non-strict at the unit type (), but the
version derived (under GHC 6.4) for isomorphic types, such as One
below, is strict.
data One = One deriving (Typeable, Data)
> toConstr (undefined :: ())
()
> toConstr (undefined :: One)
*** Exception: Prelude.undefined
Furthermore toConstr is non-strict for a bunch of other types, see
Data.Generics.Instances. To me it seems reasonable that toConstr
should be strict, since bottom is not a constructor.
(I'm not just nit-picking, a bug in one of my programs was caused by
me thinking toConstr was strict. The bug was of course easily fixed by
adding a seq, but I'd prefer consistent behaviour of toConstr.)
--
/NAD
More information about the Libraries
mailing list