Thank you all for the help. This was most helpful.<br><br>Regards,<br>Weiyuan<br><br><br><div class="gmail_quote">On Fri, May 9, 2008 at 8:16 AM, Brett G. Giles <<a href="mailto:brett.giles@ucalgary.ca">brett.giles@ucalgary.ca</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Wei<br>
<br>
Haskell needs to know that it can legally apply the function "shift".<br>
So, as requested, you need to add context to the typing of "test".<br>
<br>
if you define your function as:<br>
<br>
test :: (Data.Bits.Bits a) => a -> Int -> a<br>
<div class="Ih2E3d">test x n = shift x n<br>
<br>
</div>you should be fine.<br>
<div><div></div><div class="Wj3C7c"><br>
On Fri, 2008-05-09 at 03:10 +0800, Wei Yuan Cai wrote:<br>
> Hello,<br>
><br>
> I'm having some trouble with a polymorphic function using another<br>
> polymorphic function within. A simplified code of what I'm trying to<br>
> do is as follows:<br>
><br>
> main = print $ test 1 8<br>
><br>
> test :: a -> Int -> a<br>
> test x n = shift x n<br>
><br>
> I get the following compilation error:<br>
><br>
> Could not deduce (Data.Bits.Bits a) from the context ()<br>
> arising from a use of `shift' at test.hs:8:11-19<br>
> Possible fix:<br>
> add (Data.Bits.Bits a) to the context of<br>
> the type signature for `test'<br>
> In the expression: shift x n<br>
> In the definition of `test': test x n = shift x n<br>
><br>
><br>
> shift is defined as "a -> Int -> a"<br>
><br>
> What am I doing wrong here?<br>
><br>
> Thanks,<br>
> Weiyuan<br>
</div></div><div><div></div><div class="Wj3C7c">> _______________________________________________<br>
> Haskell mailing list<br>
> <a href="mailto:Haskell@haskell.org">Haskell@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell" target="_blank">http://www.haskell.org/mailman/listinfo/haskell</a><br>
<br>
</div></div></blockquote></div><br>