[Haskell-cafe] TDD in Haskell

Ben Millwood haskell at benmachine.co.uk
Tue May 25 08:36:08 EDT 2010


On Tue, May 25, 2010 at 12:36 PM, Ionut G. Stan <ionut.g.stan at gmail.com> wrote:
>
> Oh, and a small off-topic question? Is it considered a good practice to use
> implicit imports in Haskell? I'm trying to learn from existing packages, but
> all those "import all" statements drive me crazy.
>

It's pretty common but I don't like it. Whenever I have to debug
someone else's code usually the first thing I'll do is make all the
import lists explicit so I can work out where a troublesome function
is coming from, and that's a bit of a waste of time.

In some cases though it can get a little silly. Here is an import
statement from one of my projects:

import Language.Haskell.Exts (
 Alt (Alt),
 Binds (BDecls),
 Decl (PatBind, FunBind, InfixDecl),
 Exp (App, Case, Con, Do, If, InfixApp, Lambda, LeftSection,
  Let, List, Lit, Paren, RightSection, Tuple, Var, XPcdata),
 GuardedAlt (GuardedAlt),
 GuardedAlts (UnGuardedAlt, GuardedAlts),
 Literal (Char, Frac, Int, String),
 Match (Match),
 Op (ConOp, VarOp),
 Pat (PApp, PInfixApp, PList, PLit, PParen, PTuple, PVar, PWildCard),
 Name (Ident, Symbol),
 QName (Special, UnQual),
 QOp (QConOp, QVarOp),
 Rhs (UnGuardedRhs),
 SpecialCon (Cons),
 SrcLoc (), -- (SrcLoc),
 Stmt (Generator, LetStmt, Qualifier),
 preludeFixities,
 prettyPrint
 )

...there comes a certain point where one can probably leave the
biggest import implicit, on the basis that "if it's from nowhere else,
it's probably there".


More information about the Haskell-Cafe mailing list