[Haskell-cafe] (Num t) => [t] or [Int]

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri May 9 18:08:58 EDT 2008


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 at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list