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

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.
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 ;). -chris

On Sun, Oct 19, 2008 at 11:39 PM, Chris Eidhof
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, Jason

"Jason Dagit"
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!
Well, something I have noticed is a definitive lack of documentation on the Haskell side. With python, you get argument names for free, which makes grokking the usage of a function instant, opposed to trying to figure out (from Language.Haskell.TH, look at HApps and Parsec to see stuff that confused me much, much more) dataD :: CxtQ -> Name -> [Name] -> [ConQ] -> [Name] -> DecQ it's constraints -> typename -> something -> typedef -> implements -> result. I bet I know what goes in between the "=" and "A | B" if I want to use it, but honestly can't think of it right now. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.
participants (3)
-
Achim Schneider
-
Chris Eidhof
-
Jason Dagit