Aside from Neil&#39;s point about rank-2 polymorphism, you can of course just parameterise your NumHolder type...<div><br></div><div>data Num a =&gt; NumHolder a = NumHolder a</div><div><br></div><div>instance Show a =&gt; Show NumHolder a where</div>
<div>  show (NumHolder x) = show x</div><div><br></div><div>instance Functor NumHolder where</div><div>  fmap f (NumHolder a) = NumHolder (f a)</div><div><br></div><div>It depends what you want to do with your NumHolder though.  What is the purpose of this type?</div>
<div><br></div><div>Bob<br><br><div class="gmail_quote">On Fri, Jan 22, 2010 at 11:31 AM, Ozgur Akgun <span dir="ltr">&lt;<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear Cafe,<br><br>I can write and use the following,<br><br><span style="font-family:courier new,monospace">data IntHolder = IntHolder Integer</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">instance Show IntHolder where</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    show (IntHolder n) = show n</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">liftInt :: (Integer -&gt; Integer) -&gt; IntHolder -&gt; IntHolder</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">liftInt f (IntHolder c) = IntHolder (f c)</span><br>

<br>But I cannot generalise it to <i>Num:</i><br><br><span style="font-family:courier new,monospace">data NumHolder = forall a. Num a =&gt; NumHolder a</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">instance Show NumHolder where</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    show (NumHolder n) = show n</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">liftNum :: (Num a) =&gt; (a -&gt; a) -&gt; NumHolder -&gt; NumHolder</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">liftNum f (NumHolder c) = NumHolder (f c)</span><br><br>The error message I get is the following:<br><br><span style="font-family:courier new,monospace">    Couldn&#39;t match expected type `a&#39; against inferred type `a1&#39;</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">      `a&#39; is a rigid type variable bound by</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">          the type signature for `liftNum&#39; at Lifts.hs:54:16</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">      `a1&#39; is a rigid type variable bound by</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">           the constructor `NumHolder&#39; at Lifts.hs:55:11</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    In the first argument of `f&#39;, namely `c&#39;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    In the first argument of `NumHolder&#39;, namely `(f c)&#39;</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    In the expression: NumHolder (f c)</span><br><br><br>Regards,<br><br clear="all"><br>-- <br><font color="#888888">Ozgur Akgun<br>
</font><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>