Hello zaxis, as others have noted, you are trying to write C in Haskell. Well, that gains you nothing and rather gets you into trouble. If you want to write C, then use instead and not Haskell, because the idioms you're used to in C will not work at all in Haskell. Note for example that the 'do' keyword is misleading. It does not introduce imperative code, but monadic code, which may well be pure.
To answer your question: There are no blocks in Haskell, which you could put into braces. Don't think in blocks of code, because that is C, not Haskell, and it's plain wrong. You are not going to write any for/while loops anyway. Thinking that way may have a negative impact on your Haskell coding style. The only place where braces are used is record types and many Haskell programmers (including me) consider this an ugly syntax. But don't worry, you'll get used to the new syntax and eventually fall in love with it, because it will make your life easier. I myself came from years of C/C++ experience and had similar difficulties in the beginning. Greets Ertugrul zaxis <z_a...@163.com> wrote: > > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; > a * 2; > -- ...; > } > > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } > > will not compile without `do`. > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe