[Yhc] Haskell file to YHC.Core AST

José Miguel Vilaça jmvilaca at di.uminho.pt
Thu Jun 14 06:11:43 EDT 2007


Hi Neil,

First, thanks for all your advices; I just need to get the darcs repository
of Play and did what you said. It's now working. Thanks

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.

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.

Best
Miguel Vilaça



-----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

Hi

> 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
http://www.cs.york.ac.uk/fp/yhc/snapshot/docs/Yhc-Core-Serialise.html#v%3Alo
adCore

> 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
-id:\sources\yhc\current\depends\play

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 :)

Thanks

Neil



More information about the Yhc mailing list