On Fri, Jan 16, 2009 at 12:52 AM, Ryan Ingram <ryani.s...@gmail.com> wrote: > Here's a series of refactorings that I feel gets to the essence of the code.
Indeed it does. > Final result: >> modifyJSON f m = m { json = f (json m) } >> >> add m k v = modifyJSON go m where >> go = showJSON . toJSObject . (newEntry :) . fromJSObject . fromJust . >> jsObj >> newEntry = (k, showJSON v) > > Some stylistic choices are debatable (pointless vs. not, inline vs. > not), but I think this is a lot more readable than the >>= and liftM > madness you had going. Definitely. The refactorings you have done are very instructive and the final result just beautiful. Many many thanks. Exactly the kind of response I was hoping for. Cheers, Levi _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe