No subject


Thu Jan 10 18:17:16 CET 2013


checking, and when I get a compile error it is able extract line and column
information about where I had the error, so it appears as if GHC is
annotating the source with this information as it compiles.

I am struggling to find a lot in the way of learning materials for GHC, but
from trawling through the API documentation (I am using GHC version 7.4.2),
it seems like I can generate an abstract syntax tree via the method:

parseModule :: GhcMonad<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:GhcMonad>m
=>
ModSummary<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:ModSummary>->
m
ParsedModule<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:ParsedModule>

My question is this: what combination of functions do I have to use to get
not only an AST for my source, but an AST annotated with typing information
and line / column number annotations for values within it?

Also, as I am a bit of a newbie to this whole GHC API thing, any pointers
to resources to learn more about it would be enormously appreciated.

Thanks,

Craig

--047d7bd6b27a86a5c504d7d44f7c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>Hi there,<br><br></div><div>I am not h=
ugely familiar with compilers or the particulars of GHC, but am interested =
in creating a few programs which manipulate Haskell source code in particul=
ar ways. Two things I would like to be able to do are:<br>
</div><div><br></div>- Swap every occurrence of a particular type for a dif=
ferent / dummy value of that type.<br><br></div>- Find the line / column nu=
mber of every place a value of a particular type is used<br><br></div>From =
compiling Haskell programs, it seems clear that GHC performs type checking,=
 and when I get a compile error it is able extract line and column informat=
ion about where I had the error, so it appears as if GHC is annotating the =
source with this information as it compiles.<br>
<br></div><div>I am struggling to find a lot in the way of learning materia=
ls for GHC, but from trawling through the API documentation (I am using GHC=
 version 7.4.2), it seems like I can generate an abstract syntax tree via t=
he method:<br>
<br><a name=3D"v:parseModule" class=3D"">parseModule</a> :: <a href=3D"http=
://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:GhcMonad">=
GhcMonad</a> m =3D&gt; <a href=3D"http://www.haskell.org/ghc/docs/latest/ht=
ml/libraries/ghc/GHC.html#t:ModSummary">ModSummary</a> -&gt; m <a href=3D"h=
ttp://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:ParsedM=
odule">ParsedModule</a><br>
</div><div>
<br>My question is this: what combination of functions do I have to use to =
get not only an AST for my source, but an AST annotated with typing informa=
tion and line / column number annotations for values within it?<br><br>
</div><div>Also, as I am a bit of a newbie to this whole GHC API thing, any=
 pointers to resources to learn more about it would be enormously appreciat=
ed.<br><br></div><div>Thanks,<br><br></div><div>Craig <br></div><div><br>
<br></div></div>

--047d7bd6b27a86a5c504d7d44f7c--



More information about the Glasgow-haskell-users mailing list