Re: [Haskell-cafe] Typechecking Using GHC API

2011-12-17 Thread Daniel Schoepe
On Tue, 13 Dec 2011 18:16:17 +0100, Sh NJP shayan@gmail.com wrote:
 I do some pre-processing on a normal Haskell code ( -F ). The pre-processor
 needs to know the type of each expression.
 What are the possibilities to do so?
 Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
 Is it too naive to think of a function, f :: String - AnnotatedAST , that
 takes Haskell code and returns its corresponding abstract syntax tree
 annotated with types?

Another, less powerful, but much easier approach would be to use hint,
which also provides some type-checking functionality. Unfortunately, the
results seem to be just Strings:

http://hackage.haskell.org/packages/archive/hint/0.3.3.3/doc/html/Language-Haskell-Interpreter.html#g:7

If you want to see more examples of using the GHC API, you could also
take a look at the ghc-mod repository on github, which uses the GHC API
to provide type information to Emacs:

https://github.com/kazu-yamamoto/ghc-mod

Cheers,
Daniel


pgpBVUtUkkqQF.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typechecking Using GHC API

2011-12-15 Thread Niklas Broberg
Currently: Your only option is to use GHC API if you want type checking. I
can't help you with that, sorry.

Envisioned: The function you ask for can definitely be written for
haskell-src-exts, which I know you are currently using. I just need to
complete my type checker for haskell-src-exts first. Which is not a small
task, but one that has been started. I doubt it will be done in time for
your project though, sorry.

Best regards,

/Niklas

On Tue, Dec 13, 2011 at 6:16 PM, Sh NJP shayan@gmail.com wrote:

 Hi,

 I do some pre-processing on a normal Haskell code ( -F ). The
 pre-processor needs to know the type of each expression.
 What are the possibilities to do so?
 Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
 Is it too naive to think of a function, f :: String - AnnotatedAST , that
 takes Haskell code and returns its corresponding abstract syntax tree
 annotated with types?

 Thanks,
  /shayan

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typechecking Using GHC API

2011-12-15 Thread JP Moresmau
My own buildwrapper package (available from github and hackage) uses
both haskell-src-exts and the GHC API to provide the same kind of
services to the EclipseFP IDE plugins. You may be able to use it
directly for your purpose or at least have a look at the code to get a
feel for how to use the GHC API.

Hope this helps

JP

On Thu, Dec 15, 2011 at 11:07 AM, Niklas Broberg
niklas.brob...@gmail.com wrote:
 Currently: Your only option is to use GHC API if you want type checking. I
 can't help you with that, sorry.

 Envisioned: The function you ask for can definitely be written for
 haskell-src-exts, which I know you are currently using. I just need to
 complete my type checker for haskell-src-exts first. Which is not a small
 task, but one that has been started. I doubt it will be done in time for
 your project though, sorry.

 Best regards,

 /Niklas

 On Tue, Dec 13, 2011 at 6:16 PM, Sh NJP shayan@gmail.com wrote:

 Hi,

 I do some pre-processing on a normal Haskell code ( -F ). The
 pre-processor needs to know the type of each expression.
 What are the possibilities to do so?
 Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
 Is it too naive to think of a function, f :: String - AnnotatedAST , that
 takes Haskell code and returns its corresponding abstract syntax tree
 annotated with types?

 Thanks,
  /shayan

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
JP Moresmau
http://jpmoresmau.blogspot.com/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Typechecking Using GHC API

2011-12-13 Thread Sh NJP
Hi,

I do some pre-processing on a normal Haskell code ( -F ). The pre-processor
needs to know the type of each expression.
What are the possibilities to do so?
Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
Is it too naive to think of a function, f :: String - AnnotatedAST , that
takes Haskell code and returns its corresponding abstract syntax tree
annotated with types?

Thanks,
 /shayan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe