On Thu, Apr 12, 2012 at 6:22 PM, Antoine Latter <aslatter at gmail.com> wrote:
> Hi Warren,
>> On Thu, Apr 12, 2012 at 6:31 PM, Warren Harris <warrensomebody at gmail.com> wrote:
>> I wrote a parsec parser that does symbols lookups during the parsing process (ParsecT String Store IO a). Now I'd like to write a pretty printer that does the reverse. Unfortunately there doesn't appear to be a transformer version of Text.PrettyPrint.HughesPJ. Can anyone suggest a way to do this? Thanks,
>> It seems like the opposite would be a function of type 'a -> Store -> IO Doc'.
>> Maybe a function of type 'a -> ReaderT Store IO Doc' could be easier
> to work with.
>> If you go this route you could write a lifted versions of (<>), (<+>), hcat etc.
>> An example:
>> (<>) :: Applicative m => m Doc -> m Doc -> m Doc
On this note, there are various Wadler-Leijin pretty printers variants
on hackage, some lifted into a monad so you can do effects, IO, or
whatever. E.g. wl-pprint-extras. In my experience though WL gives
worse results than H-PJ despite having some more powerful operators.