Use a pullup resistor and capacitor network with a time big time constant (1 second or so), use the output of the optocoupler to discharge the capacitor.
The capacitor voltage will stay "low" as long as the ac signal is present.
Use a comparotor to detect if the capacitor voltage is "high" or "low".
Software is cheaper.
It turns out that a little brainstorming has led us/me to a simple circuit that does a few things for the OpenEVSE II board set. The circuit is a pair of S1M diodes from each hot line (240 VAC here in North America is delivered with a center-tapped ground reference, so each hot line is 120 VAC to ground/neutral, and each is 240 volts away from the other - because it's 180 degrees out-of-phase), wired with the anode to the respective hot line and the cathodes tied together. The common cathode line goes into a series resistor, into the anode of the LED part of the opto and then to ground (and ground specifically - not neutral like you might expect).
This circuit allows the controller to verify that a low impedance path to ground exists, and also for it to detect whether one or the other of the hot lines is actually a neutral line. The controller's own digital input pins will provide the thresholding (it doesn't have to be terribly accurate). If you don't see the line go low at least once within 10 ms or so, then that's a ground failure. If you watch it transition three times and time how long it spends low and how long it spends high, then if it's high longer (meaning the zero-crossing time plus a half-cycle), that means that one of the "hot" lines is a neutral. If it's low longer (meaning that the only high period will be near zero-crossing), that means that both of them are hot.
The diodes insure that you can't get a false-negative on the ground failure test by cross-conducting from one hot to the other.