Monadic refactoring of scene text