Game of life define the data type for Conway

hi we are trying to make game of life using haskell. I am confused how to define my data type Conway:

In src/Automata.hs, fill out the data type Conway that represents cells in the game of life. Defining our own type to talk about cells lets us be precise when we code, which reduces bugs

– | Type of cells used in Conway’s game of life. data Conway – TODO

I think learnyouahaskell has a pretty good description of creating your own types:

http://learnyouahaskell.com/making-our-own-types-and-typeclasses

In your case I think you should create a type that contains one element for cells that are ‘off’ and another element for cells that are ‘on’. That would be very similar to the boolean example, only with different names.

Types in Haskell are called algebraic data types, so you can search for that on the internet. Some other relevant pages are:

But this should really also be in your slides or textbook (I assume this is for a university course).

1 Like

yes it is an uni assignment. It was actually very simple as I though it would be, I made it very complicated for myself. So the Conway is either dead or alive so
data Conway = Allive | Dead

Thanks

1 Like