pcarbonn / pyDatalog

a datalog implementation in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static typing?

JeffreyBenjaminBrown opened this issue · comments

(Most of this duplicates a question on Stackoverflow. )

For instance[1], using the mypy library, one can specify that a function inputs a string and outputs a string, like this:

    def greeting(name: str) -> str:
        return 'Hello, {}'.format(name)

In pyDatalog, one can define (say) a unary function a single value at a time, like this:

    +(favoriteWords[0] == "cats")

Nothing prevents someone else from defining a totally-differently-typed value of favoriteWords. Is there some way to specify that the argument to favoriteWords must be a single integer, and the output must be a string?

[1] (In addition to mypy there are a number of other ways to attach type signatures; some of them are even built into later versions of Python 3.)