Studies in structure and electrochemistry of halide perovskite semiconductors and covalently-functionalized carbon with applications in optoelectronic devices, energy storage, and CO₂ capture