Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: Learning Haskell

  1. #11
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I neither know nor care much if the character from that show named Eddie Haskell had any role in the naming of the programming language under discussion. I though it might.
    Heh, that would be Haskell Curry, a very famous mathematician/logician, rather than Eddie Haskell, "The Beaver's" 'friend'

    I fear I never saw (or in fact heard of) this programme. Perhaps it only aired in America.

    Interesting mix of quotes there, by the bye. Was that part of the original phrasing?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,030
    Thanks
    44
    Thanked 3,211 Times in 3,173 Posts
    Blog Entries
    12

    Default

    I quoted "The Beaver's" because it was a unique character reference, double quotes because it already had an apostrophe. Single quotes around 'friend', because Eddie was a troublemaker.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #13
    Join Date
    Oct 2007
    Posts
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Trinithis!

    Before I answer your questions, one thing I really want to make sure you know about, because it's an incredibly useful resource, is that Haskell has an IRC channel, which is #haskell on irc.freenode.net. I highly recommend firing up an IRC client (I recommend X-Chat (Win, Linux)), and asking lots of questions there. It's very beginner friendly, and there are lots of people who will be more than happy to answer any questions you might have, or help you with code. It is by far the most useful piece of advice I could give you.

    1) What are good tutorials for Haskell?
    I recommend either the Wikibook, or "Yet Another Haskell Tutorial", up to the part where they start to talk about monads, at which point I'd strongly recommend getting a tutorial specifically about monads, as there are some much better materials in that regard. I wrote a couple tutorials on monads myself: Monads as Computation and Monads as Containers, which give two ways to look at things, that can be helpful in different cases. I also wrote an Introduction to IO, which is just about the one monad in Haskell which is used to describe I/O actions. I'd also recommend the fairly comprehensive tutorial "All About Monads", and the encouraging "You could have invented monads! (And maybe you already have)".

    2) Or better yet, is there another functional language I should learn in favor of Haskell?
    Of course, you probably shouldn't restrict yourself in the long run -- there are plenty of interesting functional languages. However, I don't think starting with Haskell is at all a bad idea. Of the 20 or 30 programming languages I know reasonably well, it is by quite a good stretch my personal favourite. Others which you might be interested in examining at some point are languages in the ML family like O'Caml or SML, as well as languages in the Lisp family like Scheme. They're not *quite* the same thing as Haskell, but if they were too similar, I probably wouldn't have mentioned them.

    3) Is functional programming radically different from imperative programming?
    Yes, most certainly. Especially so in Haskell, since it doesn't take any cop-out approaches to functional purity. Functions in Haskell, unlike functions in most imperative languages, are real, honest-to-goodness mathematical functions. This means that they only depend on their parameters, and only produce results, they have no side effects. This means they cannot quietly update and read some memory cell somewhere in order to return something different each time they're called. It also means they can't go and send stuff over the network behind your back. If you dislike bugs (and who really likes bugs?), this is great. It makes your functions easy to test: if you call your function with some parameters, and it gives the right result, then it will *always* give the right result for those parameters. There's no need to set up just the right environment for the bug to occur.

    Of course, eventually you have to deal with real input/output, because without it, your programs won't do anything but make your machine get a bit hotter. So in Haskell, we describe the I/O actions we want to have carried out with values of a special type. You might think of these values as little snippets of imperative code that we can manipulate in various ways. These actions are allowed to use all the pure functions we've written, and we can also build them up using pure functions (which is sort of like writing your own control structures). In the end, you define an action called main, and it's the only action (in a compiled program) which actually runs, built up from lots of other actions defined in your program.

    So the outlook is rather different, to say the least, and I haven't even got to lazy evaluation, or the type system yet, both of which are rather mind-altering experiences to learn about.

    4) What IDE should I use? An Eclipse plugin perhaps? Notepad?
    I personally prefer Vim and Emacs. I've heard that Windows users like to use something called TextPad, but it appears to cost money. Any editor will do, so long as it has two things: reasonably good syntax colouring support for Haskell, and the ability to automatically convert all tab characters into spaces (bonus points if it can also treat multiple spaces as a tab, or auto-indent code). You *really* don't want tab characters in your source files. If there are tab characters, they are treated by the compiler as aligning to the nearest following 8-space boundary, which means that a line starting with <space><space><tab> is the same as starting with just <tab>, or with 8 spaces. Mixing spaces and tabs causes huge headaches, so it's best to just have your editor convert all the tabs away so there's no confusion.

    See you on IRC!
    -- Cale
    Last edited by cgibbard; 10-30-2007 at 05:52 AM.

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hi Cale, welcome to DD!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Hey, thank you for your wonderful post . I'll have to bookmark the pages you gave, and I got XChat to work. Again, thanks.

    Oh, and side note: When I looked up "haskell" in two library indexes, "Leave it to Beaver" came up.
    Last edited by Trinithis; 10-30-2007 at 05:00 PM.
    Trinithis

  6. #16
    Join Date
    Dec 2007
    Posts
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have a programming question in haskell. Lets say I have the list [4,6,2,3,9,10] and I want to change the number in position 2 to be 7. The result should look like this [4,6,7,3,9,10].

    How do I do that?

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The obvious:
    Code:
    head(mylist) : 7 : tail(tail(mylist))
    will work. There may be a better way of doing it though.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #18
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Code:
    replace :: [a] -> a -> Int -> [a]
    replace (x:xs) y 0 = y : xs
    replace (x:xs) y n = x : replace xs y (n-1)
    Code:
    replace [4,6,2,3,9,10] 7 2
    Trinithis

  9. #19
    Join Date
    Dec 2007
    Posts
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks

  10. #20
    Join Date
    Dec 2007
    Posts
    0
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am pretty sure that there is a way in Haskell to use the previous result.
    ex:
    *Main> 6+7
    13
    *Main> 8+$1

    But $1 will not work. What I want basically to do is 8+13.

    Any ideas of what I should use?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •