I think records are grungy, too. I'm not sure what available options there are on Hackage, but here are some of my attempted solutions:
http://luqui.org/blog/archives/2007/08/05/haskell-state-accessors-second-attempt-composability/ And here's the automatic derivation module I said I'd write in the post: http://svn.luqui.org/svn/misc/luke/work/code/haskell/accessor/ It's all experimental, but it seems to do the trick pretty nicely. Luke On Nov 24, 2007 4:01 PM, Thomas Hartman <[EMAIL PROTECTED]> wrote: > I think I'm running into more or less the same issue discussed at > > http://bloggablea.wordpress.com/2007/04/24/haskell-records-considered-grungy/ > > Just wondering if I missed anything, or if any of the ideas > considering better records setter/getters have been implemented in the > meantime. > > t. > > > ************** > > -- Is there any way to do the following more concisely? > -- Seems like a lot of boilerplate > > data GameState = GameState { guesses :: Int, userHighScores :: > UserHighScores, answer :: Maybe Int } > deriving Show > > -- State Helpers --------------------------------------- > modGuesses f gSt = _set_guesses ( (f . guesses) gSt) gSt > modUserHighScores f gSt = _set_userHighScores ( (f . userHighScores) gSt) gSt > modAnswer f gSt = _set_answer ( (f . answer) gSt) gSt > > _set_guesses new gSt = gSt {guesses=new} > _set_userHighScores new gSt = gSt { userHighScores=new } > _set_answer new gSt = gSt { answer=new } > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
