[Haskell-cafe] prettyprint with IO

Antoine Latter aslatter at gmail.com
Fri Apr 13 03:22:50 CEST 2012


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

I haven't tried any of this, so I'm not sure if you would get any big
win over just using the first suggestion (a function of type 'a ->
Store -> IO Doc') and using the stock combinators and threading the
store around by hand.

But do let me know if something works out.

Antoine



More information about the Haskell-Cafe mailing list