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 8709389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:21:18+00:00 2026-06-13T04:21:18+00:00

Working on a chess like move calculator in Haskell and I’m running in to

  • 0

Working on a chess like move calculator in Haskell and I’m running in to a little problem
for an assignment I’m forced to use Data.Array to save my pieces in with a Position defined by a Char and an Int. Now I have a list of pieces as input with writeToArray and I’ve tried a lot but I keep getting errors, does anyone know what I’m doing wrong?

Here is the code that it’s about:

data Squares = Squares {array :: Array Pos Piece}
data Pos = Pos Char Int deriving (Eq, Ord, Ix)
data Piece = Piece { piecetype :: PieceType, color :: PieceColor } | Empty

writeToArray :: [Piece] ->(Array Pos Piece)
writeToArray (x:xs) = (((Pos 'a' 1), (Pos 'h' 8)) [((Pos char int), x) | char <- ['a'..'h'], int <- [1..8]])` : writeToArray (xs)

And the error it gives:

Couldn't match expected type `Array Pos Piece' with actual type '[a0]'

All help is appreciated greatly

  • 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-06-13T04:21:19+00:00Added an answer on June 13, 2026 at 4:21 am

    Fixed it!

    changed the writeToArray function to this:

    writeToArray :: [Piece] ->(Array Pos Piece)
    writeToArray  list = Data.Array.array (Pos 'a' 1, Pos 'h' 8) (zip  [(Pos char int)| char <- ['a'..'h'], int <- [1..8]] list)
    

    may it help other people with this problem ^_^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a game (something like chess) where every move needs to be
I'm working on to do my assignment. It is a chess design(AI, GUI not
I am working on representation of the chess board, and I am planning to
I'm working on my first proper Clojure program--a chess game. I have the following:
I'm working on a Chess-based hobby project with HTML/CSS/PHP. I wasn't familiar with chess
Here is the code : Chess(z).BackColor = #FFFFFF It is not working, how to
I am new to java and i am working on a basic chess game,
I am working on a game that uses a grid system (think chess board).
Working through C++ Primer Plus and am trying to cin data to a dynamically
I'm working on making a board game for chess and checkers (and a few

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.