Static typechecking for simple variables and functions

Fixes #18 (variable creation and definition no longer requires a type expression)

This is a starting point for a number of more complex features (e.g. user-defined functions, user-defined/library-defined primitives).
This is a complicated method and its name gives me little indication of what it does. Please improve the name and/or add some clarifying comments.