In English, when we want to use two verbs together, we normally put the second verb in the infinitive form. However, not all verbs are followed by the infinitive form of the second verb. Some verbs are followed by the infinitive, some verbs are followed by the gerund, and some verbs are followed by the base form (the infinitive form without to). Also some verbs are followed by both, the gerund and infinitive but the meaning isn`t always the same.
I stopped to smoke; I stopped smoking.
He refused to acknowledge the fact that, he his plan did not come off. She decided to take part in the competition. We`re going to meet him at the airport.
As to your question - I was shocked to discover/realize that...but you could say - I was socked at/upon discovering that...
Infinitives follow certain adjectives in a sentence
Do you think it’s challenging to speak English in front of others?
She was nervous to find out about her exam results.
Here is a list of common adjectives that can be used to follow this pattern.
ahead | amazed | anxious | ashamed | bound | careful | certain | challenging | content | delighted | determined | disappointed | eager | fortunate | glad | happy | hesitant | likely | lucky | pleased | proud | ready | reluctant | sad | shocked | sorry | surprised | upset