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

2008-05-09 Thread Brandon S. Allbery KF8NH
On 2008 May 9, at 8:28, Abhay Parvate wrote: Of course in the final code many people would recommend that you put in the type declarations as a good form of documentation, and it may be also more specialized according to your usage than what the compiler/interpreter will deduce. It's a

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

2008-05-09 Thread Abhay Parvate
You can also drop the type signature and see what type deduction you get in ghci :) Your program would have compiled well without the type signature! It's also a good exercise to come up with the most general type of a function that you write, and then compare it with the type that is deduced by dr

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

2008-05-08 Thread Wei Yuan Cai
Thank you all for the help. This was most helpful. Regards, Weiyuan On Fri, May 9, 2008 at 8:16 AM, Brett G. Giles <[EMAIL PROTECTED]> 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". >

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

2008-05-08 Thread Ross Mellgren
You gave test a type signature which gives "a" universal quantification, which means in this case that "a" is something, but you can't do anything in particular to it (since you don't know anything about it). shift has the signature a -> Int -> a, but it's within the type class Bits: Pr

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

2008-05-08 Thread Wei Yuan Cai
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.