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