We present the operation of an ultrafast passively mode-locked fibre laser, in which flexible control of the pulse formation mechanism is readily realised by an in-cavity programmable filter the dispersion and bandwidth of which can be software configured. We show that conventional soliton, dispersion-managed (DM) soliton (stretched-pulse) and dissipative soliton mode-locking regimes can be reliably targeted by changing the filter鈥檚 dispersion and bandwidth only, while no changes are made to the physical layout of the laser cavity. Numerical simulations are presented which confirm the different nonlinear pulse evolutions inside the laser cavity. The proposed technique holds great potential for achieving a high degree of control over the dynamics and output of ultrafast fibre lasers, in contrast to the traditional method to control the pulse formation mechanism in a DM fibre laser, which involves manual optimisation of the relative length of fibres with opposite-sign dispersion in the cavity. Our versatile ultrafast fibre laser will be attractive for applications requiring different pulse profiles such as in optical signal processing and optical communications.