Sheaf Semantics in Constructive Algebra and Type Theory