syntax - Issue with Haskell's "do" -


I wrote a Haskell function that calculates the factorial of each number in a given list and prints on the screen is.

  factPrint list = If put in the list of faucets, then the STRLN and STRN (show.fact.head) lists the factprint (tail list)  

The function works, but the third line is a bit confusing. Why did the compiler (GHC) not report an error on this because there is no one before "putStrLn" (semi?) Function? If I leave "Do" from the 4th row, then an error arises as expected.

I am quite new and am new to its method, so please forgive me if I am saying something very silly.

  do STRN (show.fact.head) list) factPrint (tail list)  / Code>  

There is actually another way to write

  putStrLn ((show.fact.head) list) & gt; & Gt;  

which means,

  putStrLn (list of show.fact.head))> gt; & Gt; = \ _ - & gt;  

Without these other ugly syntax, there is a convenient way to string these monads together.

If you have only one statement inside do , then you are not stringing anything together, and do is unnecessary.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -