[Haskell-cafe] Useful IDE features - What abautautomaticallyadding import statements?

Claus Reinke claus.reinke at talk21.com
Sun Jun 17 12:24:49 EDT 2007

> I've now implemented this as well. My setup is getting the information
> directly from the installed packages (thus ghc-pkg describe package and
> then ghc -show-iface eachmodule.hi) Because I use caching it
> should be reasonable fast ? (I hope so, I still have to do some testing)
> The used packages are taken from the cabal file (and / or buffer
> setting)

the more, the merrier!-) yes, caching is essential (reading in a huge
dictionary is fast, creating it is not). getting the info from ghc-pkg would
be preferable, and i do actually keep two dictionaries, one from haddock,
one from ghci's :browse. but there seems to be a lot of internal info in the 
output of --show-iface, is that useable? extracting the information from
haddock indices was the most-likely-to-work approach at the time..

linking editing sessions to .cabal files is still on my todo list;-)
>  import Foo (a)
> add identifier b
> results in
>  import Foo (a,b) 
> ? 

currently, i get:

import Foo (a) 
import Foo (b) 

which is one reason why i'd like to take existing imports into account
in some future version.

> or for the whole module it comes from (this feature 
>> gets its information from haddock's indices 
> I'm using tags and the plain source file most of the time.

yes, tags and sources are used for some features, but the standard
libs simply have no sources in the default installations.

> So I don't have trouble generating haddock documentation.
> I think its easy but I haven't spent much time on this.
> It contains all, the documentation and the implementation.

i'm not generating haddocks, just extracting information from them.
>> combined with quickfix mode, which will jump to the identifier not
>> in scope, this seems to be quite close to what you ask for?
> I'll let you know when having finished the quickfix integration.

basic quickfix settings for ghc seem fairly straightforward, see

>> HaRe also had some transformations for manipulating imports/exports.
>> http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html
> I don't know HaRe at all. Would this even work when working with #ifdef
> etc?

i don't recall whether we tried to do anything about preprocessors,
probably not. also, preprocessor directives are mostly used to work
around language differences, and none but the haskell 98 branch
would be useable with HaRe.
> I'd like to have some features, such as _T ..
> But this only works if the file can be parsed by ghc, right?

yes. both '_t' and '_T' simply use ghci's :t (:s is also available via '_si').


More information about the Haskell-Cafe mailing list