I had the same experience when writing Haskell. I would start by inserting a function call at the top level referencing a function I hadn't written yet, and then start hacking on the function and all its helpers. Without fail, as soon as the program compiled it was basically correct. The only thing that could go wrong were legitimate algorithmic errors, such as using the wrong base cases for recursion or something.