3 ms·
> 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]
by cabalamat 12y ago
> 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.
- deleted 12y ago[deleted]