Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread David McBride
Imagine if bar was a toplevel function bar = case foo of True -> " Foo"; False -> "Bar"; Keep in mind that indentation level starts at the function name, not at the let keyword. On Thu, Oct 3, 2013 at 2:31 PM, Corentin Dupont wrote: > Hi the list, > why do this function doesn't compile (parse

Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread Corentin Dupont
Thanks to all for your replies! I asked the question because I often make this kind of transformations (please don't mind the non-sensical example): test :: Bool -> IO () test foo = do bar <- case foo of True -> return "Foo" False -> return "Bar" return () into test :: Bool ->

Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread Roman Cheplyaka
On Thu, Oct 3, 2013 at 9:44 PM, Brandon Allbery wrote: > On Thu, Oct 3, 2013 at 2:31 PM, Corentin Dupont > wrote: > >> test :: Bool -> IO () >> test foo = do >>let bar = case foo of >>True -> "Foo"; >>False -> "Bar" >>return () >> >> while this one does (just adding one

Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread Brandon Allbery
On Thu, Oct 3, 2013 at 2:31 PM, Corentin Dupont wrote: > test :: Bool -> IO () > test foo = do >let bar = case foo of >True -> "Foo"; >False -> "Bar" >return () > > while this one does (just adding one space in front of True and False): > > test :: Bool -> IO () > test foo

Re: [Haskell-cafe] indentation with let and do

2013-10-03 Thread AlanKim Zimmerman
The first version has bar True and False all at the same indentation level. As such they are seen as standalone expressions, rather than being nested under the one introduced by bar. See http://en.wikibooks.org/wiki/Haskell/Indentation On Thu, Oct 3, 2013 at 8:31 PM, Corentin Dupont wrote: >