Viewing inferred types
Tue, 6 Mar 2001 16:56:28 -0500
Content-Type: text/plain; charset=us-ascii
When I edit Haskell code in a text editor, I often want to point at an
expression and be told its type. (Even assuming that this feature
only works when the entire file type-checks correctly, it would still
be very useful to me.) For example, in
let c:cs =3D "string" in ...
I would like to point at "c" and be told that
c :: Char
c:cs :: [Char]
I divide this functionality into two parts:
1. Given a Haskell program, produce a list of pairs (span, type),
where "span" is a contiguous region in the source code that parses
as an expression, and "type" is the type of the expression
(possibly universally quantified and/or with context).
2. Make this information easy to generate and view in an editor.
Focusing on part 1, I see two possible approaches:
A. Ask an existing Haskell interpreter/compiler to output the
information. I looked briefly at the implementations listed at
http://www.haskell.org; none of them seems to produce anything
(i.e., any debugging output) from which the necessary information
can be extracted. Therefore, to take this approach, we would need
to modify an implementation. I would be very happy to be
corrected on this observation.
B. Connect a Haskell parser (e.g., hsparser) to a Haskell type
checker (e.g., _Typing Haskell in Haskell_). This is the
preferred approach because the solution would not depend on the
internals of any Haskell implementation. However, the output of
hsparser is neither typed nor desugared for piping into _Typing
Haskell in Haskell_, so some conversion/desugaring work is
I would appreciate any comments, pointers to existing work, or other
help on this project. In particular, how much work would be involved
in approach B above, and has it already been done? Thanks in advance!
Edit this signature at http://rodimus.digitas.harvard.edu/cgi-bin/ken/sig
Dumpster Clocking: The tendency when looking at objects to guesstimate=20
the amount of time they will take to eventually decompose: "Ski boots are=
the worst. Solid plastic. They'll be around till the sun goes supernova."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----