
16 Jan
2009
16 Jan
'09
7:50 a.m.
On Fri, Jan 16, 2009 at 12:52 AM, Ryan Ingram
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