On Sun, Feb 22, 2009 at 12:55 PM, Marc Weber <span dir="ltr"><<a href="mailto:marco-oweber@gmx.de">marco-oweber@gmx.de</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
While working on extending scion I got some trouble and wonder which is<br>
the best way to do this?<br>
<br>
I have to pass a compilation result from a scion process instance to the<br>
scion daemon process. Of course I'd just like to use a simple Read Show<br>
for that. However I can't because two datatypes are NominalDiffTime and<br>
Bag ErrMsg:<br>
<br>
newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord)<br>
data ErrMsg = ErrMsg {<br>
errMsgSpans :: [SrcSpan],<br>
errMsgContext :: PrintUnqualified,<br>
errMsgShortDoc :: Message,<br>
errMsgExtraInfo :: Message<br>
}<br>
<br>
Both are fine and both don't export all contstructors so you can't just<br>
let ghc derive instances for it?<br>
<br>
So the only way is to duplicate those datatypes in order to derive some<br>
Show, Read instances?<br>
<br>
On the one hand I do understand that you don't want users to access<br>
constructors directly. On the other hand it would be desirable to derive<br>
Read, Show instances here.<br>
<br>
Is there a way to get all?<br>
a) hiding constructors so that you don't have to expose implementation<br>
details to the user.<br>
b) still allow deriving serialization instances?</blockquote><div><br>I usually use Data.Binary for serialization. There is a cultural standard not to do anything with Binary instances other than to pass the result of encode to decode. They are opaque blobs of bits, perfect for serialization. <br>
<br>(I think the only righter way would be to pass the information over a typed channel that respected privacy)<br><br>Luke</div></div>