[Haskell-cafe] Field updates in a state monad
scook0 at gmail.com
Thu Jan 10 19:26:52 EST 2008
On Jan 11, 2008 2:01 AM, Michael Roth <mroth at nessie.de> wrote:
> Hello list,
> Exists there a way to write this cleaner without writing countless
> "set_xyz" helper functions?
The "set_xyz" methods have to be written, but that doesn't mean *you*
have to write them. You can use Template Haskell to automatically
derive setter functions for you.
Writing the TH derivations is a little fiddly, but luckily others have
already encountered the same problem. These blog posts can point you
to a few implementations:
In particular, take a look at Luke's code, because it also contains
helper functions for combining these getters and setters with
More information about the Haskell-Cafe