Inconsistent strictness of Data.Generics.toConstr

Simon Peyton-Jones simonpj at microsoft.com
Mon Jun 6 11:24:57 EDT 2005


Yes, surely toConstr should have consistent behaviour on tuples and
other single-constructor types.  I'm inclined to agree that it should be
strict in all cases, and I'll fix Data.Generics.Instances to make it so.
Unless someone yells otherwise.

Simon

| -----Original Message-----
| From: libraries-bounces at haskell.org
[mailto:libraries-bounces at haskell.org] On Behalf Of Nils Anders
| Danielsson
| Sent: 02 June 2005 15:43
| To: libraries at haskell.org
| Subject: Inconsistent strictness of Data.Generics.toConstr
| 
| 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
| 
| _______________________________________________
| Libraries mailing list
| Libraries at haskell.org
| http://www.haskell.org/mailman/listinfo/libraries


More information about the Libraries mailing list