8 May 21:23
Re: [Haskell] Help with polymorphic functions
From: Bulat Ziganshin <bulat.ziganshin <at> gmail.com>
Subject: Re: [Haskell] Help with polymorphic functions
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-08 19:23:53 GMT
Subject: Re: [Haskell] Help with polymorphic functions
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-08 19:23:53 GMT
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 <at> gmail.com
RSS Feed