
Misha I'm happy to tell you that your wish has been granted. I was able to implement the change you wanted (you called it deferred instance declarations) as part of an overhaul of the type-class machinery in GHC. I'll send out a more detailed message about this to ghc-users. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-bounces@haskell.org] | On Behalf Of Misha Aizatulin | Sent: 27 September 2006 21:08 | To: GHC Users Mailing List | Subject: Re: [Haskell] Deferred instance declarations (serialization of existential boxes) | | Simon Peyton-Jones wrote: | > Concerning your application | > | > | I am having a box like | > | > data Box = forall a. Cxt a => Box a | > | and want to write a Read instances for it. | > | > I don’t see how it helps to defer the Read instance. | | I would defer the instance declaration till the point where I know all | types that will ever go into the box (for instance in my Main module). | The Show instance of Box would write the representation of a together | with it's type (this means Cxt should contain at least Show and | Typeable). The Read instance will then contain something like | | ======================================================== | String aType <- lexP | | result <- case aType of | "[Int]" -> | (readPrec :: ReadPrec [Int]) >>= (return . Box) | "SomeOtherType" -> | (readPrec :: ReadPrec SomeOtherType) >>= (return . Box) | | -- <more of such cases> | | _ -> error (aType ++ " cannot be read inside of Box") | ======================================================== | | Not very elegant of course, but it seems to be the only way to Read | existentials. | | > But I think the case is stronger for top-level constraints, and I will bear it in mind. | > If you would like to open a Trac feature request, please do so. | | Ok, I will. | | Cheers, | Misha | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users