
On 30 September 2010 21:02, Bas van Dijk
Note that, although I don't use it myself, the GHC flag: -ddump-minimal-imports can help you with this style:
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/separate-compilation...
Indeed, after discovering this I thought about writing a little Emacs Lisp to have a keybinding for updating my imports using -ddump-minimal-imports, so that I can write without explicit import but then make it explicit when I'm done automatically. I forgot about it so thanks for reminding me. Ideally I would also write some functions that make automatic import of a symbol easier. There are 4 problems with writing Haskell and managing imports, as I see it, right now (I'll make up some names to encapsulate these ideas): 1. Pretty printing: The order and spacing of imports. 2. Explicitness: The explicit naming of imported symbols, or qualification. 3. Discovery: Calculating where the symbol I'm using right now should be imported from, and then adding that import either automatically or with-confirmation. 4. Pruning: Removing unnecessary imports, and merging imports which are the same. I made some functions to make it easier to jump back and forth to imports, but now I don't really want to manually write out an import statement again. I'd prefer to have Emacs present me with options, i.e., these are the modules that export that type/symbol/class, pick one (with ido/fuzzy completion) and then it adds the import line at the correct place with the desired spacing and with the necessary import. You also sometimes refactor part of a module to another module, and then you need to copy over all the necessary imports. I tend to copy all my imports over and then remove the ones GHCi tells me aren't necessary. So, one solution to make this automatic copy over all the imports from the current module and then prune. Perhaps I will attempt some of this on the weekend, as it's the biggest pain I have right now writing Haskell code. I spend a lot of time just maintaining my imports.