[Haskell-beginners] Explicit specification of function types

Alexander Dunlap alexander.dunlap at gmail.com
Mon Mar 23 23:57:00 EDT 2009


On Mon, Mar 23, 2009 at 7:08 PM, Tom Poliquin <poliquin at softcomp.com> wrote:
> Zachary Turner wrote:
>> Everything I've read has said that it's generally considered good practice
>> to specify the full type of a function before the definition.  Why is this?
>
> I'm still a newbie but using (and leaving) the type definitions
> helps me quickly recall what a routine is doing and also provides
> handy documentation when I have to hack (uhh ... I mean modify)
> the code weeks later.

I agree with this. It's quite useful to be able to just look at a
function and see what its type is without having to go into GHCi and
query it. This becomes less useful for local-er variables because
their type can often be inferred from context and they are not
generally used elsewhere in the function.

Alex


More information about the Beginners mailing list