
Hi, I am working on a project that features a few modules with inter-dependent states. It is expected that some of the modules import and use some of the stateful functions from other modules, and simultaneously, need to manage the state of their own. I need to make a design choice as to whether I should add the new modules' state as separate layesr by transforming the monad transformer stack in each module, or create a separate module to handle the amalgamation of all states with a single datatype. Both solutions have salient issues. The latter, namely stacking more layers, can quickly become unwieldy, whereas the former breaches encapsulation. Any better ideas? To give it more of a concrete context, imagine the following: module A where type AState = State Int.... someAFunc :: a -> AState a --------------- module B where type BState = StateT Int AState ... someBFunc :: b -> BState b -------------- -- now I want module C to only have access to B's part of BState, but not the A-related part module C where type CState = StateT Int BState Thanks, Ali