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?

http://www.haskell.org/haskellwiki/Record_access
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to