In the solution for the Lecture #4 (cohort 1 I guess, I'm following on Youtube)
payContract :: Contract () PaySchema Text ()
payContract = do
pp <- endpoint @"pay"
let tx = mustPayToPubKey (ppRecipient pp) $ lovelaceValueOf $ ppLovelace pp
handleError (\err -> Contract.logInfo $ "caught error: " ++ unpack err) $ void $ submitTx tx
payContract
It appears that payContract calls itself, and this is required to get the payTest1 and payTest2 functions to actually run.
My question is: how does this not recurse infinitely? Where is the condition that stops it?
I'm still learning Haskell as I go and I come from a C# background, so I'm still getting my head around the functional programming thing.
TIA