We propose a new scheme for synthesizing correct declarative programs. This general scheme can be instantiated to the specific declarative paradigms, thus obtaining an integrated development environment in which it is possible to debug a program and to (partially) correct it automatically. The scheme is based on declarative diagnosis and inductive learning which are techniques which have been used in each paradigm. In our scheme the diagnosis has to identify program wrong rules w.r.t. an intended specification. Then a bug--correction, program synthesis methodology tries to correct the erroneous components of the initial code. The correction algorithm uses two sets of evidence examples. Our scheme defines a generic hybrid, top-down as well as bottom-up, algorithm for the automatic correction of declarative programs which exploits techniques of inductive learning. The top-down algorithm starts from an overly general program and refines it, while the bottom-up algorithm is used when the initial wrong program is overspecialized. The resulting program is correct w.r.t. the initial example sets.