Hi!

I have a question about guarantees that GHC provides about shape of generic
representation of data type. To be more concrete if we have two
single-constructor data types with N fields will their binary trees built from
(:*:) be balanced in same way? Same for (:+:) binary tree.

I want to use generics to write conversions between data types with same shape:

> λ> data Foo = Foo Int Char deriving (Show,Generic)
> λ> to . coerce . from $ Foo 1 'c' :: (Int,Char)
> (1,'c')
> λ> to . coerce . from $ Foo 1 'c' :: (Sum Int,Char)
> (Sum {getSum = 1},'c')
> λ> to . coerce . from $ (Sum (1::Int), 'c') :: Foo
> Foo 1 'c'

Coercion between Reps for different types is only possible when they have same shape. Quick experiments shows that they're same. I think that they should be
same but documentation is silent about this.


Thanks in advance,
Alexey
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

Reply via email to