[Haskell-cafe] Coding conventions for Haskell?

Evan Laforge qdunkan at gmail.com
Thu Sep 30 20:51:10 EDT 2010


Sorry, forgot to reply to all

> 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.

Same here, though I use exclusively qualified imports so it's not such
a hassle.  But it
adds busywork when you start a new module or want to split some code
into a new one.

The one feature I really like in eclipse is a key you hit to clean up
the imports.  It removes the unused ones, and tries to find imports
for symbols that aren't in scope.  If there are multiple
possibilities, it asks which one.  It even does this automatically
when you copy and paste code between files.  I would love something
like this for haskell.

It's easier in my case because I use exclusively qualified imports and
almost always name them as the last component after the dot, so if you
parse the source file and find 'M.a' and there's no 'import qualified
.. as M' then you just search for 'M' modules.  If I were writing this
(and I may take a shot some day), I'd write a standalone program that
filters a file, that way it works no matter what editor you use.  And
why write it in elisp when you could write it in haskell, and have
access to haskell-src?


More information about the Haskell-Cafe mailing list