Alexander Bird
Alexander Bird

Reputation: 40609

how do I print a list in haskell?

How do I print a list to stdout in Haskell?

Let's say I have a list [1,2,3] and I want to convert that list into a string and print it out. I guess I could build my own function, but surely Haskell has a function built in to do that.

Upvotes: 42

Views: 50579

Answers (1)

hammar
hammar

Reputation: 139840

Indeed there is a built in function, aptly named print.

> print [1,2,3]
[1,2,3]

This is equivalent to putStrLn $ show [1,2,3].

Upvotes: 57

Related Questions