David Waern: >> The type class could provide an interface for serializing and writing >> the state to disk. Instances could choose to use Read/Show, Binary or >> whatever they want, or am I missing something? > > That was badly explained. I mean something like this: > > class Serialize a where > read :: FilePath -> IO a > write :: a -> FilePath -> IO () > > The user then writes an instance for his main state type using Binary > or Read/Show.
Just to add my opinion on what color the bikeshed should have (sorry for that): A typeclass is of little use if you only ever use it for one type, and only call the methods in one place. Thus, passing the read/write functions as parameters makes more sense to me - as I understand it, the polymorphy of the above class Serialize wouldn't be exploited anywhere (unless you look at the code of many programs together). Put another way, the semantics “the serialization as to be used by Dyre” doesn't sound sufficiently general to be captured in a type class, as opposed to “a binary serialization” (Data.Binary) or “a human-readable presentation” (Read/Show). Regards --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---