Thursday, November 17, 2005

Yhc API

I was reading some stuff about GHC's API today - I may end up using it for my PhD. There are also a couple of other utilities I want to write - such as:

  • Type annotator, put explicit type signatures on every top level declaration
  • Minimal import calculation, to remove unneeded import statements
  • Call graph generator
  • Module dependancy graph generator
  • Tab -> Space convertor, respecting Haskell's rules
  • Haskell warnings, when you do something a bit dodgy
  • Salmon, a Haddock replacement [this is Bob's]
  • etc.
The reason I will never do any of these is it would take days to get from Haskell to an appropriate form where the stuff can be done. The actual code is probably trivial, the Haskell boilerplate parsing, type checking etc. would be horrendous. Unless there was a Yhc API :)

And hence, initial motivation for a Yhc API is born. The compiler could do with refactoring lots (and lots and lots), and working towards a publically visible API may help the internals solidify a bit. I have set up an initial wiki page here, comments welcome.

Of course, there is a Ghc API, but Ghc is a lot bigger platform. Yhc is aiming to be small, simple and straightforward - exactly the qualities I want in an API!

2 Comments:

Blogger malcolm said...

Type annotator, put explicit type signatures on every top level declaration.

Isn't this exactly what ends up in the interface .hi file? So you just need to run the compiler front-end thus far, then stitch the signatures back into the original source?

Minimal import calculation, to remove unneeded import statements

Don't nhc98 and ghc already do that? Option -report-imports or -ddump-minimal-imports respectively.

Nevertheless, I think this is a good list of small but useful utilities that would help the programmer become more productive.

8:49 PM  
Blogger Neil Mitchell said...

Re: Type Annotator

Yes, that is whats in the .hi file - for the moment. Binary .hi files look like they will be quite a big win, so this will disappear. I'm also hoping the Yhc API will make this even easier, removing the need to parse Haskell (or hacky style parse haskell) in order to figure out where the functions are, and if they have signatures already etc.

Minimal imports

I didn't know about those! Will take a look.

11:37 AM  

Post a Comment

<< Home