[Haskell] XML Serialization and type constraints
Tomasz Zielonka
t.zielonka at students.mimuw.edu.pl
Wed Aug 25 11:19:33 EDT 2004
On Wed, Aug 25, 2004 at 04:14:48PM +0100, Simon D. Foster wrote:
> I think I jumped the gun it a bit; it almost works, but when I try to
> declare a serializer for a type with several parts e.g.
>
> data Person = Person PackedString PackedString Int
>
> instance (Hook Person t) => Serializer Person t where ...
>
> If I try to call encode on any of the attributes I get;
>
> Could not deduce (Hook PackedString t)
> from the context (Serializer Person t,
> Hook Person t,
> Hook Person t)
>
> Thus, I have to add a (Hook x t) constraint for every type that is part
> of the given data-type. For your example try;
>
> data D = D Int
> instance (Mixin D t) => Serializer D t where
> encodePrim t (D n) = "(D " ++ encode t n ++ ")"
>
> Is there anyway of getting around this?
Perhaps you could just 'encode Id' that parts?
Best regards,
Tom
--
.signature: Too many levels of symbolic links
More information about the Haskell
mailing list