getting types out

Bernard James POPE
Thu, 11 Apr 2002 11:46:10 +1000 (EST)

> I know -ddump-types will get me the types of top level functions, but is
> there a way to get ghc (or really any compiler) to dump the types of
> everything (or at least more than that, maybe just locally bound
> definitions)?

Hi Hal,

I once tried to do this with an older version of GHC. From memory it
was kind-of possible with a little bit of hacking the ghc type
checking code.

What I was able to do was dump type schemes for top-bound and
let/where bound identifiers. 

It is tricky to know what to do with free variables in the scheme,
I don't think I did anything special with them.

Simon Peyton Jones asked me if I wanted to add this feature to
ghc, but I never got around to doing this, mostly because I got
distracted by other things.

In my spare time I (and a few colleagues) have been adding a parser
and other trimmings to Mark Jones' Typing Haskell in Haskell code.
Its not released and not finished, mainly due to time constraints.
The main lacking feature is multi-module programs, in particular
module interface code (partly done but not complete). However it
works enough for what I want to do. I have been thinking for a long
time that I would like to release it to others, but I have been
held back because it is incomplete and I would like some better
documentation. Also I haven't asked Mark for his permission. I also
think there are other people who are doing similar things, but we never
really communicated properly, which is a shame, I think the Haskell
Communities project should help in this respect.

My main goal with this code was to have a stand-alone tool for Haskell
that would provide detailed information about the static aspects of
a program: types, kinds, class hierarchies, identifier definitions,
binding groups and so on.

One wonders whether a better option would be to pull the front off an
existing Haskell implementation. I tried to do this with ghc, nhc and
also hugs, without success for various reasons.

It is hard to get money and Haskell programmers to work on such
projects, and so it is relegated to a spare time hobby.

I know this doesn't really answer your question, but I did once ask
the same thing...