<div>&nbsp;</div>
<div>=======================================================================</div>
<div>module Test where</div>
<div>class Arg a where<br>&nbsp; pr :: a -&gt; String</div>
<div>instance Arg Int where<br>&nbsp; pr _ = &quot;i&quot;</div>
<div>instance Arg Char where<br>&nbsp; pr _ = &quot;c&quot;</div>
<div>instance Arg a =&gt; Arg [a] where<br>&nbsp; pr _ = &quot;[&quot; ++ pr (undefined :: a) ++ &quot;]&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- the type variable &#39;a&#39; is interpreted as an unbound one.<br>&nbsp; -- (1) pr :: [a] -&gt; String<br>&nbsp; -- (2) pr (_ :: [a]) = &quot;[&quot; ++ pr (undefined :: a) ++ &quot;]&quot;</div>

<div>=======================================================================</div>
<div>&nbsp;</div>
<div>Dear All,</div>
<div>&nbsp;</div>
<div>I got some problem when I try to compile the above program.</div>
<div><br>The problem is due to the presence of a type variable &#39;a&#39; in the body of the last instance declaration.<br>How could I refer to the type variable of Arg [a] in the instance declaration?</div>
<div>&nbsp;</div>
<div>I tried these options<br>&nbsp;&nbsp; 1) by giving an explicit declaration for pr<br>&nbsp;&nbsp; 2) by giving a type signature to the argument of pr with -XPatternsSignatures</div>
<div>&nbsp;</div>
<div>The first option gives me back an error :<br>&nbsp;&nbsp;&nbsp; Misplaced type signature: pr :: [a] -&gt; String<br>&nbsp;&nbsp;&nbsp; The type signature must be given where `pr&#39; is declared</div>
<div>&nbsp;</div>
<div>The second option gives me an error:<br>&nbsp;&nbsp;&nbsp; Test.hs:21:12: Not in scope: type variable `a&#39;</div>
<div>&nbsp;</div>
<div>Would anybody help me to understand this problem?</div>
<div>&nbsp;</div>
<div>Thanks in advance.</div>
<div>&nbsp;</div>
<div>Kwanghoon</div>