[Haskell-cafe] Re: [Haskell] Probably a trivial thing for people knowing Haskell

Jason Dagit dagit at codersbase.com
Mon Oct 20 03:01:04 EDT 2008

On Sun, Oct 19, 2008 at 11:39 PM, Chris Eidhof <chris at eidhof.nl> wrote:

> I think it might be more appropriate to move this discussion to
> haskell-cafe.
> On 19 okt 2008, at 17:24, Friedrich wrote:
>> Learn to love types:  one of the neat things about Haskell is that if
>>> you can write down the type of a function then you have usually done
>>> 90% of the work of writing the code for it.
>> Well I disagree. But that's another story.
> Well, it's definitely not true when you're starting out with Haskell. The
> thing is: once you start to think in types it does work like this. You just
> think: what do I need as my input and what's my output. That's what you
> write down as your type and you're almost done! It's very similar to
> test-driven development; the point with TDD is not so much about making sure
> your program is correct: the big win (for me) is that it helps you think
> about the design of your program. The same holds for types.

Something I have noticed about myself now that I can think in types to some
degree is that reading the documentation for apis in non-typeful languages,
I'll pick on python, is now harder!  I find myself wanting to know the type
or class of types that the api will consume and produce.  Knowing that in
Haskell you can have that information even if the documentation hasn't been
written spoils you :)

>>  Another is that in
>>> general, if you can't express the type of a function, it means you
>>> haven't thought through what you're trying to do.
>> No  that's not true. The use implies that. However I'm not advice
>> resistant and will see if I use types. But IMHO that's should be job
>> of the environment  to figure out  correctly and most of the time
>> Haskell does "guess" right. And I surely can ask for the types.
> I agree. However, sometimes, when things get really complex, you can't
> figure out a way to write down the code. That's when it can be handy to
> start out from the types and slowly work towards the definition.
> At first, you'll think that types are there to make your life harder. After
> a while, you'll start to love them and to be honest: I feel quite
> uncomfortable programming in an untyped language these days ;).

My experience with learning haskell mirrors what is described here.  At
first I fought with the type system.  Over time I noticed it was right more
often than I was :)  In time I learned to take its advice and eventually I
learned to antcipate it.  Haskell will warp your brain.

Hmm...this kool-aid sure is tastey,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081020/e027de0f/attachment.htm

More information about the Haskell-Cafe mailing list