[Haskell-cafe] ghc api printing of types
lonetiger at gmail.com
Sat Jul 17 09:34:35 EDT 2010
You were right, that is the correct way of doing it, I just found out the
type I was trying to print didn't have the context at that level anymore, I
had to look one position higher in the ast.
From: Daniel Gorín [mailto:dgorin at dc.uba.ar]
Sent: Sunday, July 04, 2010 15:49
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] ghc api printing of types
I believe the way is done in hint is something like this (untested):
showType t =
do -- Unqualify necessary types
-- (i.e., do not expose internals)
unqual <- GHC.getPrintUnqual
return $ GHC.showSDocForUser unqual (GHC.pprTypeForUser False
t) -- False means 'drop explicit foralls'
Hope that helps
On Jul 4, 2010, at 8:36 AM, Phyx wrote:
> I was wondering how given a Type I can get a pretty printed type out
> of it.
> Im currently using showSDocUnqual . pprType . snd . tidyOpenType
> But this has the problem that predicates dont get printed, anyone
> know how GHCi does this?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe