5 ms·
I think the exact opposite. Finally a language where floats and integers cannot be mixed together accidentally.
by StreamBright 9y ago
I think the exact opposite. Finally a language where floats and integers cannot be mixed together accidentally.
- kcorbitt 9y agoThe type checker is capable of disallowing `float + int` while still allowing `int + int` and `float + float`, which is what I want.
- renox 9y agoWhy? As long as float -> int implicit conversion are forbidden, I don't see any issue with allowing implicit int -> float conversion.
- masklinn 9y agoHaskell does not allow accidentally mixing floats and integers together. In fact it doesn't even allow mixing finite and infinite-precision integers together, despite using the same operator for all number additions: Prelude> (3::Int) + (4::Integer) <interactive>:2:13: Couldn't match expected type ‘Int’ with actual type ‘Integer’ In the second argument of ‘(+)’, namely ‘(4 :: Integer)’ In the expression: (3 :: Int) + (4 :: Integer) In an equation for ‘it’: it = (3 :: Int) + (4 :: Integer) It's not by any means the only language with that property either.
- runeks 9y agoOff topic: why on earth does ghci print out that last “In an equation for ‘it’: it = […]” statement? Seems like something internal to ghci, and not something that’s relevant to the user.
- masklinn 9y agoYou'd have to check ghci's source itself, but I expect it just hands the bits over to GHC for evaluation and the relevant GHC API (sensibly) requires a name, for which ghci provides "it".