Live data from Hacker News

The New Haskell Homepage

new-www.haskell.org

151–160 of 258 posts

Re: The New Haskell Homepage

#151
post #145

A few thoughts: It's really distracting that typing in the REPL changes the size of the containing div. The blurry photo of (I assume) the audience of a lecture just doesn't work - what's it supposed to do? There's very little useful information - everything is at least one click away. If the whole purpose of the site is to 'sell' to a new audience then I guess that's not an issue, but I expect to be able to go to th…

Also typing in their code example (the one right at the top, pride of place) into their 'Try it' repl throws an error: primes = sieve [2..] where sieve (p:xs) = p : sieve [x | x :1:8: parse error on input `='" error Now I have almost no knowledge of Haskell, so I'm probably making some really basic mistake, but I figure most visitors will try that and then get put off

Yes, that's certainly an issue. In fact the "Try it" box also seems to work differently from the standard haskell live interpreter, in which you'd be able to define functions by prefixing them with 'let '.

If you still want to try it out, say

    let sieve (p:xs) = p : sieve [x | x 

Re: The New Haskell Homepage

#152

Please note this homepage is NOT final and it's going to see revisions before we push it out to the actual website, including many tweaks to the content and probably some styling tweaks too. There are a lot of other things we still need to do as well, like ensure all redirects and subpages work properly. Source: I'm one of the Haskell.org administrators, and we pushed this out only today.

I love the tutorial! I couldn't help writing down some notes while going through it, here they are if you're interested in reading:

- Really would love to return to previous steps to review things (for example, reviewing what the difference is between a list and a tuple)

- "You just passed the (+1) function to the map function." But didn't I also pass [1..5] to it too? It's unclear to me whether map is a function which takes two arguments ... or if the first part "map (+1)" evaluates to a function which acts on [1..5]

- Is a (+1) a tuple with one item (the function "+1") or is it just similar syntax?

- Really like the exercises and would love to have more challenges interspersing the intake of new content. It honestly feels like the best way to learn.

I'm going to sleep for the night, otherwise I'd keep going. I'll return to it later. Looks promising!

P.S. Mini-bug report: Somehow this happened and it really confused me https://i.cloudup.com/0wRJS7FZls.png - looks like my 'try it again anyways' strategy saved me here. (there were no js console errors).

Re: The New Haskell Homepage

#153

Earlier quoted context omitted.

Being a god in C++ won't give you anything regarding foreign paradigms. Are you familiar with other FP languages such as ML, Miranda or even Lisp ? More than syntax it's the semantics that differs a lot. Laziness, Immutability...

Not really. No. And that's the problem! You're right that semantics are what make the languages truly different. However it is literally impossible to even begin to understand semantics if you don't know the syntax. That's what is so frustrating. It might as well be written in Kanji. That's how meaningless it is to me and, I believe, most programmers.

That's the thing though. Because you have a ton of experience with C++, then you'd probably be able to pick up ruby, python quite quickly (if you don't know them already), because despite the superficial syntatic differences, their semantics are, in the grand scheme of things, close enough to those of C++. You'll trip up on some of the subtler differences, but you'll have a relatively easy time interpreting what the differences mean. When you first look at haskell, the underlying semantics are different enough that your prior experience scarcely helps you interpret the different syntax. Cue howls of frustration.

Re: The New Haskell Homepage

#154

Many people know C++ and Java but have no sense for functional programming. It would help them to read equivalent known code to compare it with Haskell. For instance FP Complete's Introduction to Haskell presents some ugly Java code which can be written in two elegant lines in Haskell (video around 03:25 min). http://www.youtube.com/watch?v=Fqi0Xu2Enaw

A video like this could also be cool to have on the front page.

Re: The New Haskell Homepage

#155

Please note this homepage is NOT final and it's going to see revisions before we push it out to the actual website, including many tweaks to the content and probably some styling tweaks too. There are a lot of other things we still need to do as well, like ensure all redirects and subpages work properly. Source: I'm one of the Haskell.org administrators, and we pushed this out only today.

I love the tutorial! I couldn't help writing down some notes while going through it, here they are if you're interested in reading: - Really would love to return to previous steps to review things (for example, reviewing what the difference is between a list and a tuple) - "You just passed the (+1) function to the map function." But didn't I also pass [1..5] to it too? It's unclear to me whether map is a function whi…

Not sure if you would like to know some answers to your questions, here are they anyway:

- It's unclear to me whether map is a function which takes two arguments ... or if the first part "map (+1)" evaluates to a function which acts on [1..5]

The latter is true. In Haskell you can pass arguments to functions one at a time each time the result could be a function that takes another argument. You might even say that Haskell functions always take one argument, and that Haskell's function syntax is just a bit of sugaring. The process of returning a function that takes the second argument is called a 'curry' after the man Haskell Curry.

- Is a (+1) a tuple with one item (the function "+1") or is it just similar syntax?

A tuple of 1 is just an expression. The ('s are just to determine expression scope, it's the commas that would make it a tuple. A tuple of 2 would just be 2 expressions bundled together, so I don't think there's a meaningful difference :P

Re: The New Haskell Homepage

#156
post #59

Earlier quoted context omitted.

Could you suggest a simpler example? Finding primes is something that is taught in the first programming class in Indian high schools. I guess I've never thought of it as something hard. I looked at nodejs.org, and their first example is a web server! Python has the Fibonacci as it's second example (the first one show's numeric operations). Ruby does simple string operations on it's home page. While I think that is i…

Fibonacci sounds perfect! fibonacci :: Integer -> Integer fibonacci 0 = 0 fibonacci 1 = 1 fibonacci n = fibonacci (n - 1) + fibonacci (n - 2) Arguments for this: * "Find the Nth Fibonacci Number" is among the most universally known programming tasks, so visitors are far more likely to immediately pick up the example than they are with sieve. * It shows off a bit of Haskell syntax that (A) can be learned just by looki…

That's a horrible algorithm though, it takes exponential time. Any good implementation of Fibonacci numbers would be logarithmic in the number of arithmetic operations and polynomial in overall running time (because the numbers get bigger). Here's a good implementation in Haskell: http://nayuki.eigenstate.org/res/fast-fibonacci-algorithms/f... , and the same in Python: http://nayuki.eigenstate.org/res/fast-fibonacci-algorithms/f... . BTW, I think even functional programmers would find the Python code slightly easier to follow :-)

Re: The New Haskell Homepage

#157

Earlier quoted context omitted.

Fibonacci sounds perfect! fibonacci :: Integer -> Integer fibonacci 0 = 0 fibonacci 1 = 1 fibonacci n = fibonacci (n - 1) + fibonacci (n - 2) Arguments for this: * "Find the Nth Fibonacci Number" is among the most universally known programming tasks, so visitors are far more likely to immediately pick up the example than they are with sieve. * It shows off a bit of Haskell syntax that (A) can be learned just by looki…

That's a horrible algorithm though, it takes exponential time. Any good implementation of Fibonacci numbers would be logarithmic in the number of arithmetic operations and polynomial in overall running time (because the numbers get bigger). Here's a good implementation in Haskell: http://nayuki.eigenstate.org/res/fast-fibonacci-algorithms/f... , and the same in Python: http://nayuki.eigenstate.org/res/fast-fibonacci-…

Maybe it's because I've been using Haskell exclusively for a few months, but I find the Haskell example more clear. This surprises me because I have much more experience with Python.

Re: The New Haskell Homepage

#158
post #94

Well, it sure looks nicer, I'll give you that. I'm more interested in the content, though. I was just trying here and there over the last week or so to learn some Haskell - people always seem to be raving about how cool it is. I found my way to the CIS 194 class link, the first one on the page, and I find that it really isn't very good for learning. I went through the first page, trying to run some of the stuff. I fi…

I too dislike tutorials focused around the REPL, because it's rarely how you write code in practice. The REPL is more of a debugging tool for quickly testing and manipulating code you've already written.

I'd jump directly into creating code files/modules - begin by creating simple programs using `main` as you would in other languages. Create a file with ".hs" extension, (Haskell filenames start with capital letters by convention, since they share the name of the module)

    main :: IO ()
    main = putStrLn "Hello World!"
Make sure the GHC bianries are in your PATH, and use the program "runhaskell File.hs" to quickly compile and execute them. Also, from ghci you can use the command (:load File.hs), if you want to debug stuff.

The preferred tool for writing Haskell though is emacs. If you're not familiar with emacs, its also a great opportunity to learn. Grab emacs 24, and open the file ~/.emacs, paste in this snippet:

    (require 'package)
    (add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
    (package-initialize)
Then hit M-x (M for Meta, which is typically Alt), and type eval-buffer into the minibuffer at the bottom. If no errors, hit M-x and type into the mini-buffer:

    package-install haskell-mode
You can add the following to the .emacs file and use `eval-buffer` again. Also save with C-x C-s.

    (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
    (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
Next step is to just open an empty haskell file. Create a new directory for your project with `M-x make-directory`, and create a new haskell file using C-x C-f. Add some code, and hit C-c C-l (load in ghci), and emacs will pop open a new window, launch ghci and load your code into it.

You can switch over to the ghci window with C-x o (cycle windows), and type some code into it for testing. (Note it can be quite buggy if the cursor is not in the right place - there needs to be a space after the prompt > ¦). Useful keyboard shortcuts to remember here are M-p (previous) and M-n to cycle through previously used commands. (You can rebind any keys to how you wish.)

You can also add typicall IDE features like "run without debugging" and such with simple snippets of elisp. Say if we want to bind F6 to this command, we can add this hack to .emacs, save and eval the expression.

    (global-set-key [f6] 
        (lambda () 
            (interactive) 
            (async-shell-command (concat "runhaskell " buffer-file-name))))
Now with an active haskell file, F6 will launch like an application, bypassing GHCI - and emacs will typically open a new window (or replace an existing one) with the stdout/stderror for the application.

That'll get you started anyway. From there, using LYAH is a good beginner resource, although it won't get you much further than past the syntax and semantics of the core language. It doesn't cover the plethora of language extensions, building projects, using cabal, haddock, quickcheck and more. I'm not aware of a single resource which covers these though - I just learned what was needed as and when by searching - the best information typically comes from one-off blogs focused on a specific problem.

Re: The New Haskell Homepage

#159

A few thoughts: It's really distracting that typing in the REPL changes the size of the containing div. The blurry photo of (I assume) the audience of a lecture just doesn't work - what's it supposed to do? There's very little useful information - everything is at least one click away. If the whole purpose of the site is to 'sell' to a new audience then I guess that's not an issue, but I expect to be able to go to th…

> The blurry photo of (I assume) the audience of a lecture just doesn't work - what's it supposed to do?

It has links to a bunch of lectures/videos right below it, so I'm guessing that's why it's there...

Re: The New Haskell Homepage

#160
post #94

Well, it sure looks nicer, I'll give you that. I'm more interested in the content, though. I was just trying here and there over the last week or so to learn some Haskell - people always seem to be raving about how cool it is. I found my way to the CIS 194 class link, the first one on the page, and I find that it really isn't very good for learning. I went through the first page, trying to run some of the stuff. I fi…

This http://dev.stephendiehl.com/hask/ overview is a little bit more advanced. It gives a good overview over the tools, some of the ecosystem and important libraries.
Post reply on HN