I\'m looking to write a generic module that allows Haskell programs to interact with Cassandra. The module will need to maintain its own state. For example, it will have a con
I'd go with Option 2. Users of your module shouldn't use runState
directly; instead, you should provide an opaque Cassandra
type with an instance of the Monad
typeclass and some runCassandra :: Cassandra a -> IO a
operation to "escape" Cassandra. The operations exported by your module should all run in the Cassandra
monad (e.g. doSomethingInterestingInCassandra :: Int -> Bool -> Cassandra Char
), and their definition can access the wrapped CassandraState
.
If your users need some additional state for their application, they can always wrap a monad transformer around Cassandra
, e.g. StateT MyState Cassandra
.