An algebraic framework for separate type-checking