[Haskell-beginners] Simple Chess Program for Learning FP

Jordan Cooper nefigah at gmail.com
Tue Jun 1 16:54:38 EDT 2010

On 6/1/10, Yitzchak Gale <gale at sefer.org> wrote:
> Daniel Fischer wrote:
>> If performance isn't important, you can also use a two-dimensional array
>> (Data.Array; Array (Int,Int) (Maybe Piece) for example) in Haskell.
>> Actually, immutable arrays in Haskell are surprisingly snappy (at least if
>> you compile with optimisations).
>> Another option is using Data.Map and representing the gamestate as a Map
>> from positions to pieces.
>> There are also mutable arrays,
> A chess board is only 8x8, so depending on your algorithms,
> a simple 2 dimensional list might be the fastest:
> [[Maybe Piece]]
> That also allows you to write simple, beautiful functional code, using
> the wide selection of list functions available in the Prelude
> and Data.List.
> If you choose a map from positions to pieces, it might turn out
> to be just about as fast to use a simple association list
> [(Int, Int), Maybe Piece]
> instead of all the machinery of Data.Map.Map (Int, Int) (Maybe Piece)
> A chess board has only 64 locations.
> Regards,
> Yitz
> Regards,
> Yitz
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

Thank you, Daniel and Yitzchak! I think that will be enough to get me
started. As a general question, at what number of elements does it
become impractical to use Lists?

More information about the Beginners mailing list