I imagine this is entirely possible without merging the two OS’s. When the keyboard is attached, the iPad would run MacOS and the MacOS version of an application. In fact, the keyboard could contain the boot volume for MacOS. When the keyboard is detached, the screen would revert to an iPad device and run iOS. Documents would transfer via Handoff.
I never want to see the two OS’s merged since Apple’s loyalty lies with pedestrian users/consumers rather than content creators/professionals. If an OS is compromised, it will be MacOS.