Many-sorted theories and their algebras with some applications to data types