Actually, Achim has made a very good point here.
There is a big difference between a Reed (magnetic) relay (switch), and a Hall effect sensor.
Primarily, a Reed relay will connect a switch whenever enough magnetic force is acting upon it, giving you an on/off signal. A Hall effect sensor provides a voltage level indicating how much magnetic force is being applied to it.
The code shown above would only 'directly' work with a Reed relay, which is not to say that it won't work at all for a hall effect sensor, but that it would provide additional challenges using a hall-effect sensor.
The primary challenge will be that you're treating an analog device as a digital one - expecting to trigger on rise of a pulse. Now, the signal won't be pulsed - it will be generally like a bell-curve, with all sorts of fluctuations. You might trip past the minimal voltage for a high signal (around 3.5v, IIRC?) several times as the magnet passes the hall-effect sensor.
Of course, our first instinct when using something like a hall effect sensor is to use the ADC and read the voltage level on an analog pin. However, you're limited to 10,000 reads, roughly, per second on an analog pin (each read takes 100uS). That assumes also that all you do is loop and read values - doesn't leave you much other time to update a display, calculate, etc. Not to mention, if you read at the wrong time, you missed your signal!
I'm sure it's possible to use interrupts somehow linked to the ADC, but I don't have such knowledge handy.
Instead, if you wish to use an actual Hall Effect sensor, I'd suggest feeding it into a Schmitt trigger to convert it to a digital (on/off) signal at a calibrated level that indicates "directly under the magnet." Additionally, depending on the level of hysteresis implemented in the Schmitt trigger, you may need to do some de-bouncing that would change the rate of de-bounce based on current speed. Then you could treat it like a normal Reed relay.
!c