News for hackers. Stuff that matters.
Re:Type checking in Python by pekk on Sunday May 18, 2014 @11:31AM (#7763314)
There is nothing special about map and filter, they are not idiomatic Python because there are better ways to do the same things.

Python 3 annotations are already not used in any specific predetermined way, so if you create a system to do something with type annotations then you can implement List(str) or whatever it is you want an annotation to work like.

Re:Type checking in Python by xiaq on Sunday May 18, 2014 @12:27PM (#7763450)
> There is nothing special about map and filter, they are not idiomatic Python because there are better ways to do the same things.

True, list comprehension is often used instead. But a complete typing system should be able to type-check that too. The point is not changed.

Also, I only used map and filter as an example. Python programmers tend to write a lot of generics functions without actually knowing it.

    def f(g, *args):
        ...
        r = g(*args)
        ...
        return r
This function is actually quite generic, akin to map.

And we are not yet getting into the realm of "trait" or "concept" or "typeclass" or whatever.

    def sum(*nums):
        s = 0
        for n in nums:
            s += n
        return s
Remember, although s is definitely an int, s + n may yield some completely unrelated type if n implements __radd__. The function here involves potentially infinite number of types, and their __add__ or __radd__ traits (reusing the name of the Python magic method). To fully express its type without unnecessary constraints is an interesting exercise. Since Python allows dynamic parameter list building (like sum(*nums)), dependent typing may be necessary for that purpose.
Re:Type checking in Python by crux on Sunday May 18, 2014 @01:15PM (#7763590)
Are there languages that include the strong type checking, inference, and typeclass functionality of Haskell while also being a little more forgiving in terms of purity, so that writing ordinary programs is not quite so troublesome as in Haskell?
Re:Type checking in Python by habitue on Sunday May 18, 2014 @01:23PM (#7763615)
Rust has a decent amount of type inference, traits and strong guarantees.

Ocaml/SML are both functional languages similar to haskell, and allow IO pretty much anywhere. They don't have typeclasses, (although ML people would say there's nothing you can't do with the ML module system[0]).

[0]http://lambda-the-ultimate.org/node/1558

Re:Type checking in Python by frowaway001 on Monday May 19, 2014 @07:13AM (#7766861)
Scala (although it has limited type inference to require people to specify at least the inputs to methods for readability).