[Haskell-cafe] Signature of a function

Daniel Fischer daniel.is.fischer at web.de
Tue Jan 11 11:47:39 EST 2005


Am Dienstag, 11. Januar 2005 16:45 schrieb Henning Thielemann:
> On Tue, 11 Jan 2005, Jules Bean wrote:
> > Hint: Don't put signatures on functions, then. Instead, let the
> > compiler infer the type for you! If you want to know what the type is,
> > ask GHCi with :info. And if you think it is helpful documentation, you
> > can copy-paste the correct signature from ghci into your source code!
>
> There should always be signatures. 

I do almost unrestrictedly agree!

Deciphering code without type signatures is -- except in fairly trivial cases 
-- always a nuisance, and if the author chose short names instead of telling 
ones, it is positively disgusting!
A type signature usually gives you a quick idea of what's going on even before 
you read much of the code (though admittedly a type signature
f :: a -> a -> a -> b
doesn't) and isn't much work to add.

Maybe if one is verrrry familiar with the language things are different, but 
until you reach that familiarity you are grateful for any help.

One might replace type signatures with comments, of course, and so convey 
better information, but that is more work, hence we poor ignorants will 
settle for signatures.

Humbly,
Daniel Fischer


More information about the Haskell-Cafe mailing list