[Haskell-cafe] Type Coercion

2008-05-28 Thread PR Stanley
Hi (16 :: Float) is a perfectly legitimate statement although I'm surprised that it's allowed in a type strong language such as Haskell. It's a bit like casting in good old C. What's going on here? Paul ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Thomas Davie
On 28 May 2008, at 09:34, PR Stanley wrote: Hi (16 :: Float) is a perfectly legitimate statement although I'm surprised that it's allowed in a type strong language such as Haskell. It's a bit like casting in good old C. What's going on here? It's not a coercion -- it happens at compile

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Ketil Malde
PR Stanley [EMAIL PROTECTED] writes: (16 :: Float) is a perfectly legitimate statement although I'm surprised that it's allowed in a type strong language such as Haskell. It's a bit like casting in good old C. What's going on here? The literal 16 is really shorthand for fromIntegral

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Salvatore Insalaco
2008/5/28 PR Stanley [EMAIL PROTECTED]: Hi (16 :: Float) is a perfectly legitimate statement although I'm surprised that it's allowed in a type strong language such as Haskell. It's a bit like casting in good old C. What's going on here? Don't worry: it's not a cast. Numeric constants like 16

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Abhay Parvate
To add to this: There are other constants which are polymorphic, not only numbers. Examples where you could add type signatures to make the type explicit are the empty list '[]' and the 'Nothing' constructor of 'Maybe a'. Adding type signatures to these will not be type casts, but telling the

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Andrew Coppin
PR Stanley wrote: Hi (16 :: Float) is a perfectly legitimate statement although I'm surprised that it's allowed in a type strong language such as Haskell. It's a bit like casting in good old C. What's going on here? It's not a type cast, it's a class method: class Num n where ...