Macroeconomics with Learning and Misspecification: A General Theory and Applications*