There is a Proxy data type in the Data.Tagged library for exactly this purpose, with conversions to and from Tagged. Proxy is easier to use with type annotations, but Tagged seems to be easier for the compiler to erase, since a Proxy is still an argument.<div>
<br></div><div>A less controversial proposal might be to see if it makes sense to just do the portions of this proposal suited to standardizing Data.Tagged, (removing the Data.Default dependency) even if the existing library functions are not converted.</div>
<div><br></div><div>-Edward<br><br><div class="gmail_quote">On Tue, Oct 26, 2010 at 3:36 PM, Roman Leshchinskiy <span dir="ltr">&lt;<a href="mailto:rl@cse.unsw.edu.au">rl@cse.unsw.edu.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 26/10/2010, at 19:36, Bas van Dijk wrote:<br>
<br>
&gt;&gt; How about:<br>
&gt;&gt;<br>
&gt;&gt; malloc :: Storable a =&gt; IO (Ptr a)<br>
&gt;&gt; malloc  = doMalloc Nothing<br>
&gt;&gt;  where<br>
&gt;&gt;   doMalloc       :: Storable b =&gt; Maybe b -&gt; IO (Ptr b)<br>
&gt;&gt;   doMalloc dummy  = mallocBytes (sizeOf dummy)<br>
&gt;<br>
&gt; I don&#39;t think this will work because &#39;Maybe a&#39; doesn&#39;t have a Storable instance.<br>
<br>
</div>Meh, it&#39;s late, just ignore me.<br>
<br>
This is what I was thinking while typing the above nonsense. You could redefine sizeOf and friends to take (Dummy a) instead of `a&#39; as an argument and then use this:<br>
<div class="im"><br>
data Dummy a = Dummy<br>
<br>
malloc :: Storable a =&gt; IO (Ptr a)<br>
malloc  = doMalloc Dummy<br>
where<br>
  doMalloc       :: Storable b =&gt; Dummy b -&gt; IO (Ptr b)<br>
  doMalloc dummy  = mallocBytes (sizeOf dummy)<br>
<br>
</div>In any case, for me this is not a compelling reason to break several widely used interfaces.<br>
<font color="#888888"><br>
Roman<br>
<br>
<br>
</font></blockquote></div><br></div>