Fwd: Uniplate + strict fields = fail. Why?

Hi, I've been playing with generics in general (pardon the pun) and Uniplate in particular, and found out that strict data fields somehow derail Uniplate. Observe: === code === {-# LANGUAGE DeriveDataTypeable #-} module Test where import Data.Generics (Data(..),Typeable(..)) import Data.Generics.PlateData import Data.ByteString import Data.ByteString.Char8 as C data Foo = Foo String deriving (Show, Data, Typeable) tst1 = [ Foo "a", Foo "b" ] test1 = [ show x | Foo x <- universeBi tst1 ] -- *Test> test1 -- ["\"a\"","\"b\""] data Bar = Bar ByteString deriving (Show, Data, Typeable) tst2 = [ Bar (C.pack "a"), Bar (C.pack "b") ] test2 = [ show x | Bar x <- universeBi tst2 ] -- *Test> test2 -- *** Exception: Prelude.undefined === end of code === First, I thought that instance of Data for ByteString is somehow deficient, but this is not the case. If you change definition of Foo to "data Foo = Foo !String", you would get the same error with "Prelude.undefined". Since all fields in ByteString constructors are strict, I have no joy trying to use it with Uniplate. Howere, my type-foo is not strong enough to understand what's wrong. Could someone give me a hint? PS ghc 6.10.4 uniplate 1.2.0.3 bytestring 0.9.1.4 PPS Neil Mitchell is receiving a copy of this email -- Dmitry Astapov

2009/10/1 Dmitry Astapov
Hi,
I've been playing with generics in general (pardon the pun) and Uniplate in particular, and found out that strict data fields somehow derail Uniplate.
I think this is related to Neil's bug report about Ratio: http://hackage.haskell.org/trac/ghc/ticket/2782 The issue is that the Data instance for your types is stricter than he is expecting. I don't know enough about Uniplate to work out why he can't tunnel the undefined's he's trying to send through Data by hiding then within a box. Cheers, Max
participants (2)
-
Dmitry Astapov
-
Max Bolingbroke