Arrays, lists, and strings exist only in the imagination of the programmer and as a member in some languages.
A file is a sequence of bytes, so when you want to write something, you have to encode this imaginary String / List / Array string into a sequence of bytes (via show or something from Storable , etc.).
In addition, the terminal is a sequence of bytes, which is an encoded representation of the actions necessary to show something to the user.
You have many coding methods. You can make a CSV representation of the array on foldr (\ab -> a (',' : b)) "\n" (map shows [1,2,3]) or you can print it show [1,2,3]
source share