Thanks for the casting idea. I really don't think you should think of boehm as "dirty." I mean, compared to what?
Real multi-threaded programs need to store structured data in shared memory. Just to give an example, let's say that this structured data is json. With boehm, I can load the shared json using the existing json module, and the json will be garbage collected when it's no longer referenced. Without boehm, I have to clone the code for the json parser, then alter it to use createShared. My data structures won't be garbage collected. Is that really cleaner? Or maybe, you just feel it's dirty to use shared structured data at all. If that's the case, then I don't know what to say, other than: I've spoken to many pure functional programmers who felt it was dirty to use mutation, because you can really shoot yourself in the foot with mutation. In a way, they're not wrong. But I'm not giving up on imperative programming.