To fight a monster, you just try to move onto the same space that the monster occupies.
F is the explicit fight command. Its use is to attack peaceful monsters without confirmation, attack a pet without displacing it, or strike at the suspected location of an invisible monster without moving if it is not there.
Fighting at a space containing no monster produces the message "You attack thin air."
m is an explicit move command. If you want to attempt to move onto a space without attacking its occupant then press m before selecting your direction.
The two commands are generally associated with hallucination, invisibility and blindness, since these warrant more caution than the usual move-attack function. At most other times directional control is sufficient.