Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


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


You'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".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: