News for hackers. Stuff that matters.
Re:Type checking in Python by cabalamat on Sunday May 18, 2014 @02:21PM (#7763802)
> This module doesn't seem to make it possible to type-annotate map and filter, which are Python builtins.

In Haskell map is

    map :: (a->b) -> [a] -> [b]
How could we do something like that in a Python type extension? One way would be to just use the Haskell notation in quotes:

    @type("(a->b) -> [a] -> [b]")
    def myMap(fn, as):
        #...etc...
An alternative would be to define a function Fun for describing functional types, and gen.{something} for a generic type, e.g.:

    @type(Fun(gen.a, gen.b), [gen.a], ret=[gen.b])
    def myMap ...etc...
But that notation doesn't (at least to me) look as clean as the Haskell.

There are no comments on this comment yet.