
11 Jan
2008
11 Jan
'08
12:49 p.m.
On Thu, 10 Jan 2008, Michael Roth wrote:
Hello list,
still playing with monads and states, I have the following question:
Given:
import Control.Monad.State.Lazy
data MyData = MyData { content :: String }
foobar :: State MyData String foobar = do gets content
Ok, that looks nice and tidy. But:
foobar2 :: State MyData () foobar2 = do modify $ \x -> x { content = "hello haskell"}
...looks not so nice.
Exists there a way to write this cleaner without writing countless "set_xyz" helper functions?