On Sun, Feb 22, 2009 at 12:55 PM, Marc Weber <span dir="ltr">&lt;<a href="mailto:marco-oweber@gmx.de">marco-oweber@gmx.de</a>&gt;</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&#39;d just like to use a simple Read Show<br>
for that. However I can&#39;t because two datatypes are NominalDiffTime and<br>
Bag ErrMsg:<br>
<br>
newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord)<br>
data ErrMsg = ErrMsg {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;errMsgSpans &nbsp; &nbsp; :: [SrcSpan],<br>
 &nbsp; &nbsp; &nbsp; &nbsp;errMsgContext &nbsp; :: PrintUnqualified,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;errMsgShortDoc &nbsp;:: Message,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;errMsgExtraInfo :: Message<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
Both are fine and both don&#39;t export all contstructors so you can&#39;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&#39;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&#39;t have to expose implementation<br>
 &nbsp;details to the user.<br>
b) still allow deriving serialization instances?</blockquote><div><br>I usually use Data.Binary for serialization.&nbsp; There is a cultural standard not to do anything with Binary instances other than to pass the result of encode to decode.&nbsp; They are opaque blobs of bits, perfect for serialization.&nbsp; <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>