
Hello everyone, I would like to ask for some advice regarding the type checker part of GHC. My goal is to determine the type of every expression, pattern etc. in the syntax tree. Currently the compiler doesn't store this information, so I have to type check manually. One important aspect is that the program may be ill-typed, but I still want to extract as much information as possible. I tried using local type checking functions (eg.: tcInferSigma), but whenever I used it on an expression that had some "out-of-scope" names in it, it failed.
f xs = length xs
The reason was that xs was not in the local environment. My question is: how could I provide the necessary local environment for these type checking functions? Also in the general case, is it possible to somehow annotate each expression with its type during the type checking? The motivation for this is that I want to implement a tool that automatically corrects ill-typed programs based heuristics. For that I need to know the types of certain AST nodes. Peter Podlovics