Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gelisam/conway
Demonstrating comonad transformers.
https://github.com/gelisam/conway
Last synced: 13 days ago
JSON representation
Demonstrating comonad transformers.
- Host: GitHub
- URL: https://github.com/gelisam/conway
- Owner: gelisam
- Created: 2013-06-06T03:49:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-10-09T15:57:55.000Z (about 8 years ago)
- Last Synced: 2024-10-25T09:30:08.261Z (21 days ago)
- Language: Haskell
- Size: 26.4 KB
- Stars: 36
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Comonad-Transformers Demo
=========================> ./conway-demo
#
#
###
(animates forever, press Ctrl-C to stop)If a comonad is an environment for cellular automata, then a comonad transformer adds an axis to that environment.
In this demo, we first construct a comonad representing a 1D neighborhood. We then write a slightly more complicated version which adds an extra 1D neighborhood to an existing comonad: that is our comonad transformer. If we apply the 1D neighborhood transformer to another 1D neighborhood, we obtain a 2D neighborhood.
We end the demo by implementing Conway's Game of Life on top of this 2D grid. The comonadic nature of the grid makes it very easy to specify the rules of the automata, because the code is run uniformly on each cell, and because the indexing is always relative to the current cell. Those two features are central to comonads.
Our particular version happens to use numerical indices which wrap around past the edge of the grid, but that is in no way typical of comonads.