(Num t) => [t] or [Int]

Hi I thought [1, 2, 3] :: [Int] GHC says it's (Num t) > [t] Okay, when it comes to 3.3:[1,2,3] (Num t) => [t] makes more sense. Is that the only reason? Cheers, Paul

Hello PR, Saturday, May 10, 2008, 1:07:48 AM, you wrote:
Okay, when it comes to 3.3:[1,2,3] (Num t) => [t] makes more sense. Is that the only reason?
the reason is that 1 as any other numerical constant, may be directly used as Int, Integer, Double or any other Num value. if 1 is Int, you will need to make more conversions -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On 2008 May 9, at 17:07, PR Stanley wrote:
I thought [1, 2, 3] :: [Int] GHC says it's (Num t) > [t] Okay, when it comes to 3.3:[1,2,3] (Num t) => [t] makes more sense. Is that the only reason?
The Haskell 98 standard says that numeric literals are of type Num t => t (so you don't need to fromIntegral everything that looks like an Int but is used with e.g. Doubles). Therefore a list of them is Num t => [t]. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (3)
-
Brandon S. Allbery KF8NH
-
Bulat Ziganshin
-
PR Stanley