xopgi.ql.lang.types
– The type expressions language¶
A type-expression language.
Implements the type checker/inference of chapters 8 and 9 of Book ‘The Implementation of Functional Programming Languages’ – Peyton Jones, S et al.; Prentice Hall.
Other notable sources:
- Principal type-schemes for functional programs. Luis Damas and Robin Milner. POPL ’82: Proceedings of the 9th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, ACM, pp. 207–212
- Type Assignment in Programming Languages. PhD. Thesis of Luis Manuel Martins Damas.
Note
We should see if the types in stdlib’s typing module are appropriate.
-
xopgi.ql.lang.types.
parse
(code: str, debug=False, tracking=False) → xopgi.ql.lang.types.base.Type[source]¶ Parse a single type expression code.
Return a
type expression AST
.Example:
>>> parse('a -> b') TypeCons('->', [TypeVariable('a'), TypeVariable('b')])
The AST of the type expressions¶
A very simple type-expression language.
This (at the moment) just to implement the type-checker of chapter 9 of ‘The Implementation of Functional Programming Languages’.
Note
We should see if the types in stdlib’s typing module are appropriate.
-
class
xopgi.ql.lang.types.base.
TypeVariable
(name: str, *, check=True)[source]¶ A type variable, which may stand for any type.
-
xopgi.ql.lang.types.base.
FunctionTypeCons
(a, b)¶ Shortcut to create function types
-
xopgi.ql.lang.types.base.
ListTypeCons
(t)¶ Shortcut to create list types