[Haskell-cafe] Re: About -Wall option

Yitzchak Gale gale at sefer.org
Thu Dec 6 07:07:14 EST 2007

Luis Cabellos wrote:
>> I have a question, what's the best way to program?
>>  - put all the signatures in the Haskell Code?
>>  - Only put the type signatures needed to compile (like monomorphism errors
>> or ambiguous signature)?

Wolfgang Jeltsch wrote:
> Inserting all type signatures is definitely best practice.

(Moving to the cafe from ghc-users...)

My personal style is:

o Put signatures on everything at the top-level
o Inside let and where, only where necessary, BUT:

Inside let and where, I try to make sure that every
function I define there is such that I would never want
to call it separately in ghci/hugs while debugging,
or in a unit test.

Besides making testing and debugging easier, that
rule forces the overall structure of every function to be
simple and easy to read. In that case, type signatures
just clutter the code and make it less readable.

Conversely, if the relationship between the type of
the let/where function and the type of the outer
function is complex and not obvious, I will likely need
to test that function. So it will go into a separate
top-level function with a type signature.

(I don't think this style creates any problems in Cabal.)


More information about the Haskell-Cafe mailing list