[Yhc] Haskell file to YHC.Core AST
ndmitchell at gmail.com
Thu Jun 14 06:19:53 EDT 2007
> My intension about core is that it is a Haskell subset and since I'm writing
> a tool to translate Haskell to another language, core reduces significantly
> the cases I have to deal with.
That makes perfect sense, and using Core should definitely make your
> I'm then converting Core AST to another AST (of other language). Some of the
> translation steps only need to pattern-matching over Core AST but others
> require some analysis of Core. For example, things like how many times a
> variable or a function are used inside a function definition.
In a few days there will be a release of the Uniplate library for Yhc
Core, which should make these kind of transformations much easier.
Much of it is already possible using Play - for example to see the
number of times variable 'z' is used in an expression:
length [() | Var i <- allCore x, i == "z"]
In a few days, universe will give you the answer instead of allCore.
> -----Mensagem original-----
> De: Neil Mitchell [mailto:ndmitchell at gmail.com]
> Enviada: quarta-feira, 13 de Junho de 2007 16:01
> Para: José Miguel Vilaça
> Cc: yhc at haskell.org
> Assunto: Re: [Yhc] Haskell file to YHC.Core AST
> > I see that I can read a .hs file and output a .ycr by calling in a shell
> > yhc File.hs –core
> You might also want to pass -linkcore instead, depending on your use -
> some people choose -core, some -linkcore.
> > main = system "yhc File.hs -core" >> loadcore "File.ycr" >>= writeFile
> > "File.txt" . show . trans
> > First, the YHC documentation at
> > http://www.cs.york.ac.uk/fp/yhc/snapshot/docs/doc-index.html
> > do not know about a loadcore function. Is it available ?
> It is, and its in the index, but isn't being searched for. Whats
> particularly worrying is that I wrote the code that does the
> searching, so its most likely my fault... See
> > Second, is there a way of substituting the call to system by some Haskell
> > code?
> No, not currently. I have found the system call to be perfectly sufficient.
> > Third. I'm having troubles with the binary version for windows given in
> > http://www.haskell.org/haskellwiki/Yhc/Snapshots . For a
> > Main.hs file containing
> > Where C:\tools\yhc is where I unpack the .zip file downloaded.
> If you are developing Yhc programs you will also need to check out the
> darcs repository (but not compile it). Then when doing linking you'll
> need to include something like:
> ghc --make Main.hs -id:\sources\yhc\current\src\libraries\core
> Where d:\sources\yhc\current is the Yhc darcs directory. We'll be
> releasing a .cabal package shortly which means this step will no
> longer be necessary, but shouldn't be too hard for now.
> Any hints on what you are hoping to do with Yhc.Core? We might be able
> to provide further information, and will certainly be interested to
> see the results :)
More information about the Yhc