A Constraint-based Approach to Name Binding and Type Checking using Scope Graphs