[Haskell-cafe] Signature of a function
Daniel Fischer
daniel.is.fischer at web.de
Wed Jan 12 08:33:51 EST 2005
Am Dienstag, 11. Januar 2005 18:45 schrieben Sie:
> On 11 Jan 2005, at 16:47, Daniel Fischer wrote:
> > 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!
>
> That's not really what I meant.
>
> I meant that, especially when you are figuring out a new language,
> getting the types inferred for you is helpful and also instructive... I
> wasn't suggesting that they be left out permanently.
>
> Jules
Sorry about the misunderstanding.
Yes, getting the types inferred for you is helpful and instructive, however,
as Stefan Holdermans wrote, giving a signature upfront has definite merits,
so probably the thing to do is
- write a signature first
- then comment it out and see what the System infers (and of course try to
understand that).
Concerning Keith Wansbrough and David Roundy's remarks about wrong comments, I
am miserably aware of their correctness, but I still retain the hope that
what a comment says about the overall intention of a function is more often
helpful than misleading (am I naive?) even if the details lag behind by
several updates.
Best wishes,
Daniel
More information about the Haskell-Cafe
mailing list