Electrical doping in halide perovskites