Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: why is a multi-line let expression a syntax error?

Given the following,

module Foo where

main = do
  let foo = case 0 of
    0 -> 4
  return ()

GHC insists that I have a syntax error:

Make.hs:5:5: parse error (possibly incorrect indentation)

Why? I've used Haskell for a while, and it looks correct to me.

like image 692
jameshfisher Avatar asked Aug 02 '13 19:08

jameshfisher


1 Answers

Multiline expressions in do syntax must be indented beyond the variable name:

main = do
  let foo = case 0 of
       0 -> 4
  return ()

is ok but

main = do
  let foo = case 0 of
      0 -> 4
  return ()

is not.

like image 99
seanmcl Avatar answered Oct 19 '22 06:10

seanmcl