[Haskell] [Haskell-cafe] Help with polymorphic functions

Wei Yuan Cai weiyuan.cai at gmail.com
Thu May 8 15:10:08 EDT 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell/attachments/20080509/cb9eee25/attachment.htm


More information about the Haskell mailing list