  Electron spectra measured with ALICE at mid-rapidity are used to study the production of hadrons carrying a charm or a beauty quark. The production cross section of electrons from heavy-flavour hadron decays is measured in pp collisions at $\sqrt{s}$=7 TeV. Electrons from the beauty decays are identified via the displacement from the interaction vertex. From the electron spectra measured in Pb--Pb collisions, we determine the nuclear modification factor, which is sensitive to the heavy-quark energy loss in a hot strongly interacting medium. 
Investigation of charm and beauty production via semileptonic decays of   heavy-flavour hadrons in pp at 7 TeV and Pb--Pb at 2.76 TeV with ALICE