News for hackers. Stuff that matters.
Re:Type-safe GraphQL with OCaml by StreamBright on Thursday November 30, 2017 @03:39PM (#15819302)
I think the exact opposite. Finally a language where floats and integers cannot be mixed together accidentally.
Re:Type-safe GraphQL with OCaml by masklinn on Thursday November 30, 2017 @04:12PM (#15819577)
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.
Re:Type-safe GraphQL with OCaml by runeks on Friday December 01, 2017 @11:11AM (#15824711)
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.
Re:Type-safe GraphQL with OCaml by masklinn on Saturday December 02, 2017 @06:38AM (#15831483)
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".
Re:Type-safe GraphQL with OCaml by kcorbitt on Thursday November 30, 2017 @03:42PM (#15819324)
The type checker is capable of disallowing `float + int` while still allowing `int + int` and `float + float`, which is what I want.
Re:Type-safe GraphQL with OCaml by renox on Saturday December 02, 2017 @09:29AM (#15831952)
Why? As long as float -> int implicit conversion are forbidden, I don't see any issue with allowing implicit int -> float conversion.