Skip to content

turboMaCk/pure-life-in-comonad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life Using Comonad

This is a implementation of Conway's Life in purescript using Comonad. The goal of this project was to implement generic comonadic data-structure useful for writing cellural automatons using ad hoc polymorphism and then build the Life on top. This program also includes FRP evolving simulation with rendering to Canvas.

Instead of infinite grid the Grid data-structure is "repeating" itself infinitely. Last and first cell in a zipper are acting as neighbors. You can visualize this as a grid drawn on a surface of a sphere if you wish. The lowest level implementation is done in Data.Array.Zipper module which defines basic zipper using native Array. This type implements Show, Eq, Functor, Extend, Comonad, Foldable and Traversable type classes. Data.Grid is build as Zipper (Zipper a) and implements Show, Eq, Functor, Extend and Comonad. Life itself is then defined with Life module using Grid Boolean in straight forward way.

UI for defining initial state isn't part of this program. Instead initial state is hardcoded to Glider - the emblem of hackers. All UI implementation can be found in Main module.

This was my first project in pure-script and therefore I'm not going to publish any part of this implementation as a library. Anyway feel free to use any code from this repository if you want to (BSD 3 Clause).

Installation

First make sure you have all dependencies installed. Assuming you have node.js on your machine run:

$ npm install -g bower pulp purescript

Then install dependencies of this project using bower:

$ bower install

and build project using pulp:

$ pulp --watch browserify -O --to dist/Main.js

Now you can open index.html in your browser.

Credits and Resources

Many good resources published by good people were used as studying material for this project. To name at least few:

License

BSD 3 Clause

About

Conway's Game of Life Using Comonad

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published