[Haskell-cafe] "Read-only" functions in State Monad

Benja Fallenstein benja.fallenstein at gmail.com
Sat Jun 30 20:55:14 EDT 2007


Hi Ken,

2007/7/1, Ken Takusagawa <ken.takusagawa.2 at gmail.com>:
> I'd like to have a state monad with the feature that I can somehow
> annotate using the type system that some functions are only going to
> read the state and not modify it.

I would suggest declaring a MonadReader instance for State, and
writing your read-only functions as

f :: MonadReader s m => Param -> m Result

Would that solve your problem?

Best,
- Benja


More information about the Haskell-Cafe mailing list