Chris Angelico <ros...@gmail.com> writes: > If you say "x = 5" and pass it to a function that accepts "Int or > String", the compiler knows that it's actually an Int. If you then > also pass that x to something that takes "Int or List", is that legal?
You'd have to do that with type classes, but yeah, the compiler figures out that x is an Int. > If so, then 5 is separate from the "or String" and "or List" parts, > and Nothing is actually typed. If not, then it's x, not Nothing, that > has the type. Not sure what you mean there. Haskell is statically typed which means all expressions including literals have types. And an equality like x = y + z requires the two sides of the equality to have the same type. So if you say x = Nothing and the compiler infers (from some other place in the program) that x has type Maybe String, then the Nothing you wrote also has type Maybe String. -- https://mail.python.org/mailman/listinfo/python-list