Code Monkey home page Code Monkey logo

pure-life-in-comonad's Introduction

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

pure-life-in-comonad's People

Contributors

turbomack avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.