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

8 May
2008
8 May
'08
7:23 p.m.
Hello Wei, Thursday, May 8, 2008, 11:10:08 PM, you wrote:
test :: a -> Int -> a
shift is defined as "a -> Int -> a"
not exactly ;) this type signature is given inside class Bits, where 'a' isn't a free variable (as in standalone signature declaration), but means 'a' from type class header: class Num a => Bits a where shift :: a -> Int -> a so, this declaration is equivalent to the following standalone one: shift :: (Bits a) => a -> Int -> a from the common sense POV, you can't shift *ANY* type 'a', but only types that belong to the Bits class. so, shift cannot have signature w/o class, and the same remains true for `test` -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
6269
Age (days ago)
6269
Last active (days ago)
0 comments
1 participants
participants (1)
-
Bulat Ziganshin