I recommend creating a variant type that expresses the type you are storing in your array, and tagging the entry as a variant. This would look like this:
type TextOrNat = {
#text: Text;
#nat: Nat
};
var list: [TextOrNat] = [#text "some text", #nat 0, #text "0"];
Reflection in motoko has been an often requested feature. There are apparently issues with implementing it:
If you absolutely must have it, you may have some success with GitHub - edjCase/motoko_candid. You need to to_candid your object into a candid format and then parse through the resultant object.
This would be useful if you were trying to read the memory store of a canister that just dumped state to a blob array and that contained unknown types and you were trying to marshal them to known types.