[Haskell-cafe] Type Coercion
ketil at malde.org
Wed May 28 03:55:34 EDT 2008
PR Stanley <prstanley at ntlworld.com> 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 (16::Integer)"¹, which
is a perfectly good expression for any member of the Num class --
¹ Possibly it's ::Int?
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe