Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to write a multiline comment in Haskell

Gutha Vamsi Krishna


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.

Single line comment

-- Use two hyphens to comment a single line of code.

Multiline comment


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")


  • Lines 4–7: We add comments to these lines using multiline syntax so the compiler will ignore the statements present in it.



View all Courses

Keep Exploring