Comments are non-executable statements that are used to describe the program. They are useful while reviewing another's code because they help us to understand the logic behind the code.
Each language uses a different syntax to add the comments the source code. We will use the syntax below to add the comment in Haskell.
Let’s have a look at the syntax for the single line and multiline comment.
-- Use two hyphens to comment a single line of code.
{-This is the syntax of multiline comments in haskell-}
Multiline comments start with a flower bracket and a hyphen, {-
, and close with a hyphen and a flower bracket -}
. We'll add comments to the lines between.
Let us take a look at an example below.
main :: IO()main = do{-print("This line won't print")print("This line is commented using multiline comment syntax"-}print("Hello World")