Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:09:54+00:00 2026-05-28T07:09:54+00:00

I was trying to make Tic Tac Toe game for the monthly tutorial and

  • 0

I was trying to make Tic Tac Toe game for the monthly tutorial and wrote this code to make a box first:

box :: [String]
box = ["0 | 1 | 2",
       "---------",
       "3 | 4 | 5",
       "---------",
       "6 | 7 | 8"]

I get this output in GHCi:

["0 | 1 | 2\n","---------\n","3 | 4 | 5\n","---------\n","6 | 7 | 8\n"]

I wanted to get:

 0 | 1 | 2
 ---------
 3 | 4 | 5
 ---------
 6 | 7 | 8

How can I print the grid like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:09:55+00:00Added an answer on May 28, 2026 at 7:09 am

    Try something like:

    box = unlines $ ["0 | 1 | 2",
                     "---------",
                     "3 | 4 | 5",
                     "---------",
                     "6 | 7 | 8"]
    

    Then output the box using putStr:

    main = putStr box
    

    What unlines does is take a list of strings and join them together using newlines. It basically treats the list of strings as a list of lines and turns them into a single string.

    putStr just prints the string to STDOUT. If you used print or GHCi to look at the string instead, newlines would be rendered as \n rather than actual newlines. This happens because the show instance of a String is designed to serialize the string as you would have inputted it rather than printing it. Both print and GHCi use show before outputting to STDOUT.

    If you are at the GHCi prompt and want to see what the string actually looks like, you can use putStr directly:

    *Main> putStr box
    0 | 1 | 2
    ---------
    3 | 4 | 5
    ---------
    6 | 7 | 8
    *Main>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a really simple Tic-Tac-Toe game. I have stored values
I have read a book and am trying to make a game of tic-tac-toe
I am trying to make tic tac toe using websockets running on glassfish. I've
im trying make one replace in string from a array but this dont work
Trying to make this simple applet - the first part just creates a simple
I'm writing a Tic Tac Toe Game and I would like to know how
I'm trying make this code which is from a Dictionary of Arrays (CODE) from
Trying to make this script go random. I tried variations of this string $banner_no
I'm trying make my first python app. I want make simple email sender form.
I've been banging my head against a wall trying make this work for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.