News for hackers. Stuff that matters.
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 `:{ ... }:`.