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
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
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
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
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
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
...