Writer monad corresponds to synthesized attribute?

I have been attempting to translate something I did using UUAG into monadic code. It involved inherited, synthesized, and chained attributes. It has been said that such attributes correspond to the Reader, Writer, and State monads, respectively [1]. The former and latter are straightforward, but I'm somehow missing the correlation between the Writer monad and synthesized attributes. I couldn't figure out the appropriate combination of tell/listen/pass/censor to do what I was doing with a synthesized Map. I eventually gave up and passed the synthesized values along with the monadic result. Has anybody done this before? Regards, Sean [1] http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue4/Why_Attribute_Gra...

Hi Sean Synthesized attributes are a bit more general than a Writer as there is no restriction to monoidal values. I might have re-worked UUAG code to monadic code before, but if I did it would have been simple stuff and I think I'd have just used State, or maybe State + Reader. Best wishes Stephen
participants (2)
-
Sean Leather
-
Stephen Tetley