AFTER A CAMPAIGN marked by much bloodshed, Haiti is to vote for president today -- its first free election for president in three decades. The violence of the past five months has arrived in several stages. It began in June as a popular uprising when Gen. Henri Namphy's caretaker government tried to take over the independent electoral commission. Then in late summer another wave of killings began, this one an attempt to derail, by terror, the whole election process. Some Haitians got rich under the dictatorship and correctly see their franchises and monopolies threatened. The former regime's gunmen are still around and well armed. In response, safety patrols have sprung up in many neighborhoods, and the fighting has now widened.

Against this ominous background, the process of setting up polls and distributing ballots is going forward. It is work that requires real courage. President Reagan did as much as he could do by sending a team of American observers -- most of whom, although not all, have been admitted to the country. Other governments have done the same thing. Haiti's many friends abroad are going to some lengths to strengthen the probability that today's voters will be able to trust the results as they are reported.

But the new government will necessarily be inexperienced, while the antidemocrats will be more anxious than ever to see it collapse. Haiti is a country with little in the way of police or security forces. The army tries to act as a kind of gendarmerie, but the soldiers -- badly trained, badly equipped, frightened and trigger-happy -- have only contributed to the general atmosphere of lawlessness.

As the new government struggles to restore peace, it will need more from the wealthy democracies than observers. The United States is already sending economic aid -- not enough, but as a practical matter, the budget quarrel here makes any great increase unlikely. There are other kinds of useful assistance, particularly in law enforcement and the establishment of an independent court system.

Haiti is trying desperately to break the pattern that has gripped its history for nearly two centuries. Repeatedly, its people have managed to overthrow a despot only to endure chaos and bloodshed that leads to another despotism to maintain civil order. Haiti has now forced out the Duvaliers, written new law and, despite the recent killings, carried out an election campaign. Those are substantial achievements, but building a democracy is slow work, and Haiti is now approaching the crucial point at which an elected government actually takes control