News for hackers. Stuff that matters.
Re:Functional Programming 101 with Haskell by hamburglar on Thursday January 23, 2014 @11:49PM (#7113384)
As a complete and total haskell noob, I am unable to even get through your syntax examples:

Prelude> sumOfElements [] = 0

<interactive>:12:18: parse error on input `='

Re:Functional Programming 101 with Haskell by gizmo686 on Friday January 24, 2014 @12:02AM (#7113421)
This defiantly falls under Haskell not being noob friendly.

If you are in the REPL, you want to do `let sumOfElements [] = 0`

If you want multiline input, you open with `:{` and close with `:}`. Both of these need to be on their own line. For example:

    Prelude>:{
    Prelude| let sum [] = 0
    Prelude|     sum (x:xs) = x + sum xs
    Prelude|:}
As tdinkar points out, it is often easier to define your functions if a file and load that file from the REPL.
Re:Functional Programming 101 with Haskell by hamburglar on Friday January 24, 2014 @12:07AM (#7113428)
aha, i tried using 'let' on the assumption that he was just being brief, but I put a 'let' in front of each of the pattern-matching function signatures, which didn't work. Thanks.

edit: I take your last comment as "when using the REPL, it is easier not to use the REPL." :D

Re:Functional Programming 101 with Haskell by brandonbloom on Friday January 24, 2014 @12:19AM (#7113458)
Since Haskell has a strong divide between compile and runtime, the REPL is this weird pseudo-runtime. It's best not to think of it like a REPL except for very simple use cases and instead think of it like a command prompt that you can evaluate some portion of Haskell in.

If you type `:help` you'll see all of the colon-commands that make up the command language. I'm not a Haskell expert, but my naive workflow tends to be a lot of usage of `:reload`. As a Lisper, I kinda feel like the colon commands should have been the default (sans colon) and one of the commands should have been `eval <haskel code>`.

Re:Functional Programming 101 with Haskell by mercuryrising on Friday January 24, 2014 @03:55AM (#7113981)
Check out IHaskell - https://github.com/gibiansky/IHaskell

It lets you do multiline stuff, and you get to see the output right away. You don't need let, or to repeat the "main = do ..." every time you want to run a block of code.

I think it's really helpful when you're starting out.

Re:Functional Programming 101 with Haskell by andrus on Friday January 24, 2014 @12:55PM (#7116247)
Neat, I knew about `:set +m` for enabling multiline input, but not `:{ ... }:`.
Re:Functional Programming 101 with Haskell by coolsunglasses on Friday January 24, 2014 @12:01AM (#7113418)
You're using the REPL, where every operation is basically happening in a do monad.

If you get an error like that where you intend to define something, use let.

like: let sumOfElements [] = 0

Re:Functional Programming 101 with Haskell by gizmo686 on Friday January 24, 2014 @12:07AM (#7113429)
I believe you mean that every operation is happening in the IO monad, and you input is being interpreted as if it was in a do block.
Re:Functional Programming 101 with Haskell by coolsunglasses on Friday January 24, 2014 @02:04AM (#7113728)
Sorry, yes, misspoke (so to speak) because I had friends waiting for me to queue a Dota 2 game :)
Re:Functional Programming 101 with Haskell by tdinkar on Thursday January 23, 2014 @11:53PM (#7113397)
Start with downloading the hydra.hs file I linked to in the end.

Haskell is not like ruby, it's a bit harder to define functions in the interpreter. It's easier to put them in a .hs file and then :load file.hs

Re:Functional Programming 101 with Haskell by navbaker on Friday January 24, 2014 @12:00AM (#7113413)
Since this is a 101, you might want to put your Haskell setup URL and any file dependencies/explanations of Haskell's idiosyncrasies at the top of the tutorial. A 101 is aimed at people who don't know anything about the language and assuming knowledge is a good way to ensure folks get frustrated and never come back.