[Haskell-cafe] Re: Displaying infered type signature of 'offside' functions

Georg Sauthoff g_sauthoff at web.de
Sat May 5 12:32:57 EDT 2007


Simon Peyton-Jones <simonpj at microsoft.com> wrote:

Hi,

> The principal difficulties here are to do with "what do we want" rather the implementation challenges.

yes, I thought that too (I mean a haskell compiler have to deal with 'the'
wanted information already for typechecking purposes etc.).

> 1.  Should the compiler print the type of every declaration? 

With -tdump-types, yes.

> Should GHCi allow you to ask the type of a local decl?

Yes.

> 2.  How should the variables be identified?  There may be many local bindings for 'f', so you can't say just ":t f".  Ditto if dumping all local bindings.

Well, for where-bound ones at least I would consider something like

:t f$g$h
or
:t f.g.h

as a useable command to identify this h:

f ... = ..
  where
    g ... = ...
    where
      h ... = ...

If the hierachy is not unique, :t could print all matches, and if the
user wants to be more specific, he could issue something like
:t f#2.h

for the last h in someting something like
f ... = ...
  where
    h ... = ...
f ... = ...
  where
    h .. = ...

Well, something like :t f.g.* would be nice, too, where * works like
in 'pattern globbing' (i.e. matching all decls local to  f.g).

> 3.  Do you want all locally-bound variables (including those bound by lambda or case), or just letrec/where bound ones?   I think 'all', myself, but there are a lot of them.

I just thought about where/let bound ones. But I am not sure ;)

> 4.  (This is the trickiest one.)  The type of a function may mention type variables bound further out.  Consider
>         f :: [a] -> Int
>         f xs = let v = head xs in ...

Have to think about it.

> These are all user-interface issues.  If some people would like to thrash out a design, and put it on the Wiki, I think there is a good chance that someone (possibly even me) would implement it.

Sounds great! I will wait a few days, if someone extends this thread and
then put the ideas from this thread on a wiki-page and post the link
(if not someone else do it first).


Best regards
Georg Sauthoff



More information about the Haskell-Cafe mailing list